Using rv with Quarto
rv works well with Quarto documents and projects, but there are a few important considerations when using the two together.
Packages Not Found During Render
Section titled “Packages Not Found During Render”rv sets the R session’s library paths using a .Rprofile file at the project root. Therefore, when an R session starts from that directory,
the .Rprofile is sourced and the library paths are set.
This becomes an issue when rendering Quarto documents from subdirectories. The R sessions to render the R code start within the subdirectory,
thus do not properly source the project root’s .Rprofile.
Recommended Fix
Section titled “Recommended Fix”In order to resolve this issue, a .Rprofile must be present within the subdirectory which sources the project root .Rprofile (i.e. source("../.Rprofile")).
For example, if the quarto doc of interest is two subdirectories within the project, a .Rprofile containing source("../../.Rprofile")
must be added.
Directorymy-project/
Directoryscripts/
Directoryreports
- my-report.qmd
- .Rprofile contains
source("../../.Rprofile")
Directoryrv/scripts
- activate.R
- .Rprofile contains `source(“rv/scripts/activate.R”)
- rproject.toml
quarto render Renders Package Documentation
Section titled “quarto render Renders Package Documentation”By default, quarto render recursively scans all subdirectories in your project,
including the rv/ directory. The issue arises when it finds .Rmd files for package documentation within the rv/library/ and attempts
to render them using your current R environment. This can cause errors when those documentation files reference packages not available in your project,
but can also just be a nuisance to have to render even when they render without error.
Recommended Fix
Section titled “Recommended Fix”Option 1: Exclude the rv library within your _quarto.yaml (Recommended)
Section titled “Option 1: Exclude the rv library within your _quarto.yaml (Recommended)”The simplest solution is to exclude the rv/ directory from Quarto’s rendering process by adding it to your _quarto.yml configuration:
project: type: default render: - "*.qmd" - "!rv/"This works great for simple projects, but can become bulky and complex for larger projects like multi-page websites.
Option 2: Project Structure Reorganization
Section titled “Option 2: Project Structure Reorganization”Alternatively, restructuring the project so that the Quarto content is within a subdirectory will keep rv from the discoverable path.
Directorymy-project/
Directoryrv/
- …
- rproject.toml
- .Rprofile
Directoryquarto-content/
- _quarto.yml
- index.qmd
- .Rprofile