Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.rcsignore file not ignoring files #568

Closed
aylapear opened this issue Mar 8, 2022 · 14 comments · Fixed by #684
Closed

.rcsignore file not ignoring files #568

aylapear opened this issue Mar 8, 2022 · 14 comments · Fixed by #684
Labels
bug an unexpected problem or unintended behavior deploy ⛹️

Comments

@aylapear
Copy link

aylapear commented Mar 8, 2022

I am trying to use the .rcsignore file to ignore a couple large data files in the app that do not need to be deployed to shinyapps.io. Each time the file is still uploaded to shinyapps.io. I am able to have these files ignored when I used the appFiles argument in deployApp().

I also noticed this file does not appear in the Files pane of RStudio unless I go into the More settings and select 'Show Hidden Files'.

@kevinushey
Copy link
Contributor

The ignore file name should be .rscignore, rather than .rcsignore. Is it possible the file name was misspelt?

@nick-youngblut
Copy link

@kevinushey could you possibly provide some more information about how the .rscignore file functions beyond all that I could find for docs in rsconnect (from the deployApp() function:

The files and directories to bundle and deploy (only if upload = TRUE). Can be NULL, in which case all the files in the directory containing the application are bundled, with the exception of any listed in an .rscignore file. Takes precedence over appFileManifest if both are supplied.

Must one list ALL files/directories that should be ignored in the .rscignore, or does the .rscignore have the same functionality as .gitignore (e.g., the use of wildcards)? The latter would be especially useful since the developer should just symlink their .gitignore file to .rscignore in order to ignore the same files for pushing/publishing to GitHub and Connect.

@kevinushey
Copy link
Contributor

kevinushey commented Jan 13, 2023

Based on the implementation, it looks like we just do a plain setDiff():

rsconnect/R/bundle.R

Lines 99 to 106 in 3fbc8ce

# checks for .rscignore file and excludes the files and directories listed
if (".rscignore" %in% contents) {
ignoreContents <- readLines(".rscignore")
contents <- setdiff(
x = contents,
y = ignoreContents
)
}

It'd be worth considering if we could do something smarter here; e.g. even just supporting regular expressions or something. (Perhaps that's worth filing as a separate feature request?)

@kevinushey
Copy link
Contributor

There's some documentation for it here:

rsconnect/R/bundle.R

Lines 189 to 192 in 3fbc8ce

#' \item{In order to stop specific files in the working directory from being
#' listed in the bundle, the files must be listed in the .rscignore file.
#' This file must have one file or directory per line with no support for
#' wildcards.}

but that's definitely not going to be the first place people look to find documentation, so we should probably elevate this to something else (e.g. a vignette)

@nick-youngblut
Copy link

Thanks @kevinushey for feedback!

@kevinushey
Copy link
Contributor

@aronatkins, any sense on whether this would be worth triaging for an upcoming rsconnect release?

@hadley
Copy link
Member

hadley commented Feb 20, 2023

I just fixed this in passing, by accident.

@nick-youngblut
Copy link

I just fixed this in passing, by accident.

So now the .rscignore has the same functionality of .gitignore (e.g., wildcards and normalized paths)?

@hadley
Copy link
Member

hadley commented Feb 21, 2023

@nick-youngblut no, it actually works as documented.

@kevinushey
Copy link
Contributor

Should we keep this issue open to track extending the way one might specify ignored files in .rscignore? (Or open that as a separate issue, and close this one as complete re: documentation of current behaviour)

@hadley hadley added bug an unexpected problem or unintended behavior deploy ⛹️ labels Feb 21, 2023
@hadley hadley closed this as completed in 29ccb69 Feb 22, 2023
@ColinFay
Copy link

Hey,

I'm not sure this function works as expected for folders?

Doc says :

In order to stop specific files in the working directory from being listed in the bundle, the files must be listed in the .rscignore file. This file must have one file or directory per line with no support for wildcards.

But this doesn't seem to work for folers.

Reprex :

/tmp % Rscript -e 'pak::pak("rstudio/rsconnect");packageVersion("rsconnect")'
[REDACTED]
[1] ‘0.8.29.1’
/tmp % Rscript -e 'golem::create_golem("reprexrsconnect")'
[REDACTED]
/tmp % cd reprexrsconnect

This works as expected for one file

reprexrsconnect % echo 'DESCRIPTION' >> .rscignore   
reprexrsconnect % ls
DESCRIPTION     NAMESPACE       R               dev             inst            ma
reprexrsconnect % Rscript -e 'rsconnect::listBundleFiles(".")'
$contents
 [1] ".here"                    ".Rbuildignore"           
 [3] "dev/01_start.R"           "dev/02_dev.R"            
 [5] "dev/03_deploy.R"          "dev/run_dev.R"           
 [7] "inst/app/www/favicon.ico" "inst/golem-config.yml"   
 [9] "man/run_app.Rd"           "NAMESPACE"               
[11] "R/app_config.R"           "R/app_server.R"          
[13] "R/app_ui.R"               "R/run_app.R"             

$totalFiles
[1] 14

$totalSize
[1] 15838

This doesn't with either

  • folder
reprexrsconnect % echo 'dev/' >> .rscignore
reprexrsconnect % Rscript -e 'rsconnect::listBundleFiles(".")'
── [.Rprofile] Sourcing user-wide rprofile ────────────────────────────────────────────────────────────────────────────────────────────────────────────
$contents
 [1] ".here"                    ".Rbuildignore"           
 [3] "dev/01_start.R"           "dev/02_dev.R"            
 [5] "dev/03_deploy.R"          "dev/run_dev.R"           
 [7] "inst/app/www/favicon.ico" "inst/golem-config.yml"   
 [9] "man/run_app.Rd"           "NAMESPACE"               
[11] "R/app_config.R"           "R/app_server.R"          
[13] "R/app_ui.R"               "R/run_app.R"             

$totalFiles
[1] 14

$totalSize
[1] 15838
  • folder/file
colinfay@Colins-MBP reprexrsconnect % echo 'dev/01_start.R' >> .rscignore         
colinfay@Colins-MBP reprexrsconnect % Rscript -e 'rsconnect::listBundleFiles(".")'
── [.Rprofile] Sourcing user-wide rprofile ────────────────────────────────────────────────────────────────────────────────────────────────────────────
$contents
 [1] ".here"                    ".Rbuildignore"           
 [3] "dev/01_start.R"           "dev/02_dev.R"            
 [5] "dev/03_deploy.R"          "dev/run_dev.R"           
 [7] "inst/app/www/favicon.ico" "inst/golem-config.yml"   
 [9] "man/run_app.Rd"           "NAMESPACE"               
[11] "R/app_config.R"           "R/app_server.R"          
[13] "R/app_ui.R"               "R/run_app.R"             

$totalFiles
[1] 14

$totalSize
[1] 15838

Here is the content of the file:

reprexrsconnect % cat .rscignore 
DESCRIPTION
dev/
dev/01_start.R

@ColinFay
Copy link

Ok so as far as I can tell, ignoreBundleFiles arrives with the following contents:

contents
 [1] ".here"         ".Rbuildignore" ".rscignore"    "app.R"         "DESCRIPTION"   "dev"           "inst"          "man"           "NAMESPACE"    
[10] "R" 

But

readLines(file.path(dir, ".rscignore"))
[1] "dev/02_dev.R"

and

 ignoreContents <- readLines(file.path(dir, ".rscignore"))
contents <- setdiff(contents, c(ignoreContents, ".rscignore"))

[1] ".here"         ".Rbuildignore" "app.R"         "DESCRIPTION"   "dev"           "inst"          "man"           "NAMESPACE"     "R"  

This would work as expected if recursiveBundleFiles did

 list.files(dir, all.files = TRUE, no.. = TRUE, recursive = TRUE)

instead of

 list.files(dir, all.files = TRUE, no.. = TRUE)

Happy to discuss a PR here

@hadley
Copy link
Member

hadley commented Mar 15, 2023

@ColinFay could you please file an new issue with reprex? You can use the now exported listDeploymentFiles() to simplify things.

@ColinFay
Copy link

Sure, I wasn't sure I had entirely understood the doc, hence my answer here :)

I'll open an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior deploy ⛹️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants