I tried rendering a qmd in which I used a package I manually updated, that is also provided by an R-image already installed.
In my R set-up packages are in 3 different directories. One with base R, one with packages included in an R image and one with manually installed packages. When manually installing newer versions of the packages provided in the R image, loading them usually results in loading the manual installation, as the corresponding directory is the first entry in .libPaths(). However, when rendering a qmd the library search path order seems to get mixed up and I end up with the older package versions from the R image, because they are found first.
To reproduce:
You need a similar set-up where the latest version of readr is in the first directory listed by .libPaths() and an older version of readr is in a library path with lower search order.
Run the code below in a qmd file and then render it.
---
title: "library_paths_example"
format: html
editor: visual
---
```{r}
packageVersion("readr")
.libPaths()
```
You should see that the order and package version differ between the output within the qmd and the rendered html. I am not sure what causes the reordering of the library search paths but I guess you might have to play around with the path directory naming if it does not work right away.
I am using quarto version 1.3.450
As a work around it is possible to pass the library path when calling library() by setting the argument lib.loc = path, i.e. library(readr, lib.loc = path).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With