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

Working with renv and blogdown, a few remarks on the current state #597

Closed
solarchemist opened this issue Mar 8, 2021 · 1 comment
Closed

Comments

@solarchemist
Copy link

solarchemist commented Mar 8, 2021

At the present, there is nothing stopping us from making each blog post an renv project, but apart from blogdown not actually using the renv environment (#469), there are a few small gotchas.

You really need to add the renv directory to your ignoreFiles list. Without this, Hugo will traverse the renv tree during its site build, and inevitably choke on the first HTML file it encounters there.
You probably want to add the renv.lock file to your ignoreFiles list. If we don't Include renv.lock in ignoreFiles Hugo will publish that file alongside your HTML file, which is usually not desirable.

ignoreFiles: 
  - "\\.Rmd$"
  - "\\.Rmarkdown$"
  - "\\.Rproj$"
  - "\\.RData$"
  - "\\.Rhistory$"
  - "\\.Rnw$"
  - "\\.pdf$"
  - "\\.sqlite.*$"
  - "_cache$"
  - "\\.knit\\.md$"
  - "\\.utf8\\.md$"
  - "renv"   # if you're on blogdown v0.21+, don't use any trailing slash!
  - "renv\\.lock$"

blogdown::build_site(...) now knows to skip the renv tree (note that this is hard-coded, and not dependent on your ignoreFiles), but blogdown::check_site() still peruses the renv/ tree inside each blog post, which makes it unnecessarily chatty (but does not really break anything), for example:

― Checking content files
| Checking for validity of YAML metadata in posts...
● [TODO] Found invalid YAML metadata in the following files:

  content/post/2015-02-07-rod-with-conformal-layer/renv/library/R-4.0/x86_64-pc-linux-gnu/tikzDevice/NEWS.md (Reason: Scanner error: while scanning a simple key at line 4, column 1 could not find expected ':' at line 5, column 1
)

  Please fix the YAML metadata of these files.
[...]
● [TODO] Found 221 incompatible .html files introduced by previous blogdown versions:
### [I am purposely not showing all 221 rows here...]
  file.remove(c(
  "content/post/2014-09-13-xray-line-energies/renv/library/R-4.0/x86_64-pc-linux-gnu/ggplot2/doc/ggplot2-specs.html",
  "content/post/2015-03-20-sem-tiffinfo/renv/library/R-4.0/x86_64-pc-linux-gnu/tibble/doc/formats.html",
  "content/post/2019-01-20-rstudio-server-multiple-instances-kvm/renv/library/R-4.0/x86_64-pc-linux-gnu/knitr/examples/knitr-spin.html",
  "content/post/2020-11-17-measurement-errors/renv/library/R-4.0/x86_64-pc-linux-gnu/units/doc/measurement_units_in_R.html"
  ))

  To fix, run the above command and then blogdown::build_site(build_rmd = "newfile").

If you, like me, are interested in using renv together with blogdown, I suggest you start by skimming through issues #451 and #469. Thanks to @cderv for asking me to collect my thoughts on the subject into one issue. I hope this does not confuse the subject.

@yihui
Copy link
Member

yihui commented Mar 15, 2021

Both problems mentioned in this issue should be fixed now: check_config() will suggest ignoring renv and renv.lock, and check_content() will ignore renv folders. Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants