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

paper.Rmd assumes rocker image has already installed devtools, git2r, here #89

Closed
ntrlshrp opened this issue Jul 26, 2019 · 4 comments
Closed

Comments

@ntrlshrp
Copy link

Some recent versions of rocker/verse, e.g., 3.5.3, may not have all packages explicitly used in paper.Rmd default (i.e., devtools, git2r, here), all of which are required to knit paper.Rmd. That is, Dockerfile with rocker/verse:3.5.3 fails with Quitting from lines 89-91 (paper.Rmd) Error in loadNamespace(name) : there is no package called 'here'.

@benmarwick
Copy link
Owner

Thanks for noting this, could you give a more specific report of the conditions under which you observe this problem?

I'm not sure that adding install.packages in the Rmd, as you do in #90, is the best way to fix this. If you do that, then each time the Rmd is knit those packages will be installed, which in many cases in unnecessary and wasteful.

If you are noticing this error on travis, then probably we should put the install.packages function in the dockerfile. That's why we need a bit more information from you before we can decide what is the best fix.

As a point of etiquette, could you please wait for some discussion of your issue before proposing a pull request? We are all volunteers here, and a thoughtful discussion before writing any code will save everyone's time and ensure a productive and respectful exchange of ideas.

@ntrlshrp
Copy link
Author

I can absolutely do pull requests after discussion! :) Here's a better bug report:

Expected behavior: Docker can build the default paper.Rmd on recent versions of rocker/verse

Actual behavior: Using rocker/verse:3.5.3, Dockerfile fails with Quitting from lines 89-91 (paper.Rmd) Error in loadNamespace(name) : there is no package called 'here'

Steps to reproduce:

  1. In R, devtools::install_github("benmarwick/rrtools")
  2. rrtools::create_compendium("rrtoolsTEST")
  3. Switch to new project/package rrtoolsTEST
  4. rrtools::use_dockerfile()
  5. Change rocker/verse:### to rocker/verse:3.5.3 in rrtoolsTEST/Dockerfile line 1
  6. Switch to Terminal where current directory is rrtoolsTEST/
  7. docker build --rm -t rrtoolstest:1.0 . (you may need to prepend sudo)
  • Note: this is not Travis
Quitting from lines 89-91 (paper.Rmd) 
Error in loadNamespace(name) : there is no package called 'here'
Calls: <Anonymous> ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>

Execution halted
The command '/bin/sh -c . /etc/environment   && sudo apt-get update   && sudo apt-get install libudunits2-dev -y   && R -e "devtools::install('/<REPO>', dep=TRUE)"   && R -e "rmarkdown::render('/<REPO>/analysis/paper/paper.Rmd')"' returned a non-zero code: 1`

Notes:

  • rocker/verse:3.5.3 ---> f60a16c11f35

Potential solutions (very open to others' thoughts which likely see a better way to do this):

  • Add any packages used by default paper.Rmd (e.g., devtools, git2r, here) to the Imports field of the DESCRIPTION file for rrtoolsTEST (currently, Imports: bookdown)
  • Try to install any packages used by default paper.Rmd in the .Rmd itself
if(!require(somepackage)){
    install.packages("somepackage")
    library(somepackage)
}
  • Let the user resolve the error

@nevrome
Copy link
Collaborator

nevrome commented Jul 29, 2019

I can reproduce the issue.

@benmarwick Do we really need this Colophon section in the paper.Rmd?

##### pagebreak

### Colophon

This report was generated on `r Sys.time()` using the following computational environment and dependencies: 

``{r colophon, cache = FALSE}
# which R packages and versions?
devtools::session_info()
``

The current Git commit details are:

``{r}
# what commit is this file at? 
git2r::repository(here::here())
``

Removing it solves the problem. And in my opinion it's better not to clutter the paper repo images with these heavy dependencies just for some default text. Or am I missing something?

Otherwise I vote for the first solution suggested by @ntrlshrp:

Add any packages used by default paper.Rmd (e.g., devtools, git2r, here) to the Imports field of the DESCRIPTION file for rrtoolsTEST (currently, Imports: bookdown)

This can be added here, I guess:

add_desc_package(pkg, "Imports", "bookdown")

@ntrlshrp
Copy link
Author

Picking this back up:

  • I like the Colophon, it gives everyone the "key" to the reproducible output so that everyone is on the same page in discussions about errors, typos, citations, etc. (perhaps similar to a "Recommended Citation" in a technical report with the addition of an automatically generated pointer to code and environment).

This thread hasn't received much action, so I wonder if others like any of the following for a PR:

  1. Removing [the Colophon]

  2. Add any packages used by default paper.Rmd (e.g., devtools, git2r, here) to the Imports field of the DESCRIPTION file for rrtoolsTEST (currently, Imports: bookdown)

  3. Other

  4. No PR

benmarwick added a commit that referenced this issue Aug 20, 2019
To cover the situation where the compendium is acquired without it's git repo (e.g zip download or from a data repo such as OSF). Not really a solution to #89, but this commit is a side-effect of that discussion.
benmarwick added a commit that referenced this issue Aug 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants