Reproducibility with renv, docker+renv, and rix

Author

Armand Favrot, Cédric Midoux, Pierre Neuvial

Introduction

We consider three options to reproduce Armand’s Computo paper: Favrot and Makowski (2024)

  • locally, using only renv
  • using docker + renv
  • using rix

The GitHub repository for the paper is available on the Computo page.

renv

renv is an R package that allows you to manage the versions of packages used in an R project. It is a tool that promotes code reproducibility. It can be installed from the CRAN. For more information, see the GitHub page.

Warning

renv does not manage the R version or system libraries. Code reproducibility may be compromised, for example, by a new version of R or a new version of Ubuntu.

Theoritical steps to reproduce a paper from Computo:

  1. Clone the GitHub repository of the paper.
$ git clone git@github.com:computorg/published-202312-favrot-hierarchical.git
  1. If the repository is an R project (contains a .Rproj file), open it in RStudio. Otherwise, make it an R project by going to RStudio: File > New Project > Existing Directory > path_to_the_folder.

  2. Use the renv::restore() function to install the required packages for the project (ensuring the correct versions). These packages are listed in the renv.lock file.

  3. Install the Computo extension (see section 1.4 of the template for contribution to computo). In a terminal at the root of the project:

$ quarto add computorg/computo-quarto-extension
  1. Open the .qmd file that contains the source code of the paper, and render it with the ‘Render’ button. The html and pdf files will be generated in ./site/.

In practice, it can be a little bit more tricky.

Here is how it went on a computer with ubuntu 22.04.3 LTS and R version 4.4.1.

At step 2) there was no .Rproj file in the repository. We created one and we got this message in the console:

Bootstrapping renv 1.0.3 ---------------------------------------------------
- Downloading renv ... OK
- Installing renv  ... OK

 Using R 4.4.1 (lockfile was generated with R 4.2.2)
- Project '~/test_reproductibilite_computo/published-202312-favrot-hierarchical' loaded. [renv 1.0.3]
- One or more packages recorded in the lockfile are not installed.
- Use `renv::status()` for more details.

Here we see that the version of R that was used when the paper was published (R 4.2.2) is not the same as the current version (R 4.4.1).

When using renv::status(), we got a table with the packages that are listed in the renv.lock file.

 package       installed recorded used
 askpass       n         y        ?   
 assertthat    n         y        ?   
 backports     n         y        ? 
 ...

At the end of the table, there was this message:

See ?renv::status() for advice on resolving these issues.
Warning message:
The 'yaml' package is required to parse dependencies within this project
Consider installing it with `install.packages("yaml")`. 

After installing the yaml package and checking the help of renv::status function, we used renv::restore() to install the packages recorded in the renv.lock file. Note that in case the correct versions are already installed, renv will not install it again.

renv::restore() lead to an error:

Error in .make_numeric_version(x, strict, .standard_regexps()$valid_numeric_version) : 
  invalid non-character version specification 'x' (type: double)

That was due to the difference between the current R version and the one that was used when the paper was published (see here).

At this point, we looked for a way to use different versions of R on a same computer. And we found rig, an R installation manager (see the dedicated report).

After solving a signature problem of Mattermost that poped up when trying to install the 4.2.2 R version with rig:

The repository 'https://deb.packages.mattermost.com stable InRelease' is not signed.

And switching to the 4.2.2 R version, the renv::restore() worked.

The next step was to insall the Computo extension in the project.

$ quarto add computorg/computo-quarto-extension
ERROR: Unknown command "add". Did you mean command "rune" ?

We meant add. The problem was due to the version of quarto that was too old. We had to reinstall it with sudo apt install quarto.

At this point it was time to render. We clicked on the Render button of RStudio.

- The project is out-of-sync -- use `renv::status()` for details.

processing file: published-202312-favrot-hierarchical.qmd
Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/home/mmip/.cache/R/renv/cache/v5/R-4.2/x86_64-pc-linux-gnu/stringi/1.7.6/bba431031d30789535745a9627ac9271/stringi/libs/stringi.so':
  libicui18n.so.66: cannot open shared object file: No such file or directory
Calls: .main ... namespaceImport -> loadNamespace -> library.dynam -> dyn.load
Execution halted

Unable to locate an installed version of R.
Install R from https://cloud.r-project.org/

We executed renv::status() to see the details:

The following package(s) are out of sync [lockfile -> library]:

RSPM -----------------------------------------------------------------------
- xfun   [repo: CRAN -> RSPM; ver: 0.30 -> 0.47]


See ?renv::status() for advice on resolving these issues.

We installed the correct version of the xfun package with renv::install(packages = "xfun@0.30").

And then, when executing renv::status() again:

No issues found -- the project is in a consistent state.

Nice.

Let’s try render again.

processing file: published-202312-favrot-hierarchical.qmd
Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/home/mmip/.cache/R/renv/cache/v5/R-4.2/x86_64-pc-linux-gnu/stringi/1.7.6/bba431031d30789535745a9627ac9271/stringi/libs/stringi.so':
  libicui18n.so.66: cannot open shared object file: No such file or directory
Calls: .main ... namespaceImport -> loadNamespace -> library.dynam -> dyn.load
Execution halted

After looking for a solution on google that didn’t came, we finally asked chatGPT and we were able to solve the problem. The problem was that the version 66 of the ICU library was missing on the system.

When we checked the version of libicui18n.so version available on the system, with:

$ ls /usr/lib/x86_64-linux-gnu/libicui18n.so.*

We got only:

/usr/lib/x86_64-linux-gnu/libicui18n.so.60  
/usr/lib/x86_64-linux-gnu/libicui18n.so.70

We installed the 66 version:

$ wget http://archive.ubuntu.com/ubuntu/pool/main/i/icu/libicu66_66.1-2ubuntu2_amd64.deb
$ sudo dpkg -i libicu66_66.1-2ubuntu2_amd64.deb
$ sudo ldconfig

And then the Render worked.

docker + renv

dockerfile

FROM rocker/verse:4.2.2
RUN git clone https://github.com/computorg/published-202312-favrot-hierarchical.git /home/favrot
WORKDIR /home/favrot
RUN git checkout v1.0

ARG QUARTO_VERSION="1.5.56"
RUN curl -L -o /tmp/quarto-linux-amd64.deb https://github.com/quarto-dev/quarto-cli/releases/download/v${QUARTO_VERSION}/quarto-${QUARTO_VERSION}-linux-amd64.deb
RUN sudo apt install /tmp/quarto-linux-amd64.deb
RUN rm /tmp/quarto-linux-amd64.deb

RUN quarto add --no-prompt computorg/computo-quarto-extension
RUN Rscript -e 'renv::install("pak")'
RUN Rscript -e 'pak::pak("rjags")'
RUN Rscript -e 'renv::restore()'

RUN quarto render
EXPOSE 80

CMD ["python3", "-m", "http.server", "80"]
  • We use the rocker/verse:4.2.2 image as base image (https://rocker-project.org/images/).

Install R from source and set RSPM as default CRAN mirror
Adds tidyverse packages & devtools
Adds tex & publishing-related package

We manually select the R version from the renv.lock file (this should be optimized).

  • We clone the repository and set the working directory.

  • We install a newest version of Quarto for the computo-quarto-extension.

  • The rjags package requires specific syslibs, so we use pak to install it.

  • We can now easily restore the environment using the lock file.

  • quarto render

  • The website is served on port 80 with Python’s HTTP.

Step-by-Step

  1. Build the Docker image:

    docker build --pull --tag cmidoux/favrot .
  2. Run the Docker container:

    docker run -p 80:80 cmidoux/favrot
  3. Open the website:

rix

Quoting the documentation:

rix is an R package that leverages Nix, a powerful package manager focusing on reproducible builds. With Nix, it is possible to create project-specific environments that contain a project-specific version of R and R packages (as well as other tools or languages, if needed). This project-specific environment will also include all the required system-level dependencies that can be difficult to install, such as GDAL for packages for geospatial analysis for example. Nix installs software as a complete “bundle” that include all of the software’s dependencies, and all of the dependencies’ dependencies and so on. Nix is an incredibly useful piece of software for ensuring reproducibility of projects, in research or otherwise.

Installation

First Nix should be installed, see dedicated vignette.

Then the R package rix should be installed:

install.packages("rix", repos = c(
  "https://b-rodrigues.r-universe.dev",
  "https://cloud.r-project.org"
))
library(rix)

Using rix to build project specific environments

See dedicated vignette

path_default_nix <- "/tmp/rix-test"

rix(
  r_ver = "latest",
  r_pkgs = c("dplyr", "ggplot2"),
  system_pkgs = NULL,
  git_pkgs = NULL,
  ide = "rstudio",
  project_path = path_default_nix,
  overwrite = TRUE,
  print = TRUE
)
# This file was generated by the {rix} R package v0.9.1 on 2024-09-12
# with following call:
# >rix(r_ver = "159be5db480d1df880a0135ca0bfed84c2f88353",
#  > r_pkgs = c("dplyr",
#  > "ggplot2"),
#  > system_pkgs = NULL,
#  > git_pkgs = NULL,
#  > ide = "rstudio",
#  > project_path = path_default_nix,
#  > overwrite = TRUE,
#  > print = TRUE)
# It uses nixpkgs' revision 159be5db480d1df880a0135ca0bfed84c2f88353 for reproducibility purposes
# which will install R version latest.
# Report any issues to https://github.com/b-rodrigues/rix
let
 pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/159be5db480d1df880a0135ca0bfed84c2f88353.tar.gz") {};
 
  rpkgs = builtins.attrValues {
    inherit (pkgs.rPackages) 
      dplyr
      ggplot2;
  };
    
  system_packages = builtins.attrValues {
    inherit (pkgs) 
      R
      glibcLocales
      nix;
  };
 
  wrapped_pkgs = pkgs.rstudioWrapper.override {
    packages = [  rpkgs  ];
  };
 
in

pkgs.mkShell {
  LOCALE_ARCHIVE = if pkgs.system == "x86_64-linux" then  "${pkgs.glibcLocales}/lib/locale/locale-archive" else "";
  LANG = "en_US.UTF-8";
   LC_ALL = "en_US.UTF-8";
   LC_TIME = "en_US.UTF-8";
   LC_MONETARY = "en_US.UTF-8";
   LC_PAPER = "en_US.UTF-8";
   LC_MEASUREMENT = "en_US.UTF-8";

  buildInputs = [  rpkgs  system_packages  wrapped_pkgs ];
  
}

### Bootstrapping isolated, project-specific, and runtime-pure R setup via Nix ###

==> Existing isolated nix-R project folder:
 /tmp/rix-test 

* current R session running outside Nix environment and not from RStudio

==> Added `.Rprofile` file and code lines for new R sessions launched from:
/tmp/rix-test

* Added the location of the Nix store to `PATH` environmental variable for new R sessions on host/docker RStudio:
/nix/var/nix/profiles/default/bin

==> Also adjusting `PATH` via `Sys.setenv()`, so that system commands can invoke key Nix commands like `nix-build` in this RStudio session outside Nix


### Successfully generated `default.nix` and `.Rprofile` ###

To start using this environment, open a terminal in the folder containing default.nix (i.e.) /tmp/rix-test and use the following Nix command:

cd /tmp/rix-test
nix-build

Indeed within Rstudio this may fail with:

nix-build: /usr/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.38' not found (required by nix-build)
nix-build: /usr/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.38' not found (required by /nix/store/4z754a0vzl98asv0pa95i5d9szw5jqbs-lowdown-1.0.2-lib/lib/liblowdown.so.3)
nix-build: /usr/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.38' not found (required by /nix/store/hinq0w2cd8rzw32hwz3pm3x0bvv0l0qa-nix-2.23.3/lib/libnixexpr.so)

whereas it works well with GLIBC_2.35 from a standard terminal. Moreover, glibc is a system library that should not be updated manually. See also: https://github.com/NixOS/nixpkgs/issues/287764

One can then do nix-shell and use R from this shell:

$ nix-shell
unpacking 'github:NixOS/nixpkgs/36a9aeaaa17a2d4348498275f9fe530cd4f9e519' into the Git cache...
[nix-shell:/tmp/rix-test]$ 

Note that the prompt specifies that we are in a Nix session.

[nix-shell:/tmp/rix-test]$ R

R version 4.4.1 (2024-06-14) -- "Race for Your Life"
Copyright (C) 2024 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library("dplyr")

Attaching package: ‘dplyr’

The following objects are masked from ‘package:stats’:

    filter, lag

The following objects are masked from ‘package:base’:

    intersect, setdiff, setequal, union

Case study: reproducing Armand’s Computo paper

We clone the repo of the paper (in a temporary directory in order to avoid nested R projects and nested git projects)

$ cd /tmp/
$ git clone git@github.com:computorg/published-202312-favrot-hierarchical.git
Cloning into 'published-202312-favrot-hierarchical'...
remote: Enumerating objects: 356, done.
remote: Counting objects: 100% (22/22), done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 356 (delta 15), reused 14 (delta 14), pack-reused 334 (from 1)
Receiving objects: 100% (356/356), 62.41 MiB | 2.32 MiB/s, done.
Resolving deltas: 100% (182/182), done.

We install the quarto extension for computo:

$ cd /tmp/published-202312-favrot-hierarchical
$ quarto add computorg/computo-quarto-extension
Quarto extensions may execute code when documents are rendered. If you do not 
trust the authors of the extension, we recommend that you do not install or 
use the extension.
? Do you trust the authors of this extension (Y/n)  Yes
[✓] Downloading
[✓] Unzipping
    Found 1 extension.

The following changes will be made:
Computo Format Template   [Install]   0.2.5 (formats)
? Would you like to continue (Y/n)  Yes

[✓] Copying
[✓] Extension installation complete

? View documentation using default browser? (Y/n)  n
Installing system dependencies via rix

According to https://b-rodrigues.github.io/rix/articles/building-an-environment-for-literate-programming.html it can be done via the option system_pkgs. Note that it is also possible to specify LaTeX packages to be installed, via the option tex_pkgs:

path_default_nix <- tempdir()

rix(r_ver = "4.3.1",
    r_pkgs = c("quarto"),
    system_pkgs = "quarto",
    tex_pkgs = c("amsmath"),
    ide = "other",
    shell_hook = "",
    project_path = path_default_nix,
    overwrite = TRUE,
    print = TRUE)

The R packages used in this publication are managed using the R package renv. So we retrieve the R version and the packages listed in the renv.lock file (note that this cannot be done from another project, so this command is not evaluated here):

> status <- renv::status("/tmp/published-202312-favrot-hierarchical")
> R_version <- status$lockfile$R$Version
> R_version
[1] "4.2.2"
> pkgs <- names(status$lockfile$Packages)
> str(pkgs)
 chr [1:110] "DBI" "MASS" "Matrix" "R6" "RColorBrewer" "askpass" ...
> saveRDS(list(version = R_version, pkgs = pkgs), file = "repro_favrot.rds")

We then use these info to setup a configuration file for Nix via rix:

info <- readRDS("repro_favrot.rds")
R_version <- info[["version"]]
pkgs <- info[["pkgs"]]
library(rix)
path_default_nix <- "/tmp/published-202312-favrot-hierarchical"
rix(
  r_ver = R_version,
  r_pkgs = pkgs,
  system_pkgs = "quarto",
  git_pkgs = NULL,
  ide = "rstudio",
  project_path = path_default_nix,
  overwrite = TRUE,
  print = TRUE
)
# This file was generated by the {rix} R package v0.9.1 on 2024-09-12
# with following call:
# >rix(r_ver = "8ad5e8132c5dcf977e308e7bf5517cc6cc0bf7d8",
#  > r_pkgs = pkgs,
#  > system_pkgs = "quarto",
#  > git_pkgs = NULL,
#  > ide = "rstudio",
#  > project_path = path_default_nix,
#  > overwrite = TRUE,
#  > print = TRUE)
# It uses nixpkgs' revision 8ad5e8132c5dcf977e308e7bf5517cc6cc0bf7d8 for reproducibility purposes
# which will install R version 4.2.2.
# Report any issues to https://github.com/b-rodrigues/rix
let
 pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/8ad5e8132c5dcf977e308e7bf5517cc6cc0bf7d8.tar.gz") {};
 
  rpkgs = builtins.attrValues {
    inherit (pkgs.rPackages) 
      DBI
      MASS
      Matrix
      R6
      RColorBrewer
      askpass
      assertthat
      backports
      base64enc
      bit
      bit64
      blob
      broom
      bslib
      callr
      cellranger
      cli
      clipr
      coda
      colorspace
      cowplot
      cpp11
      crayon
      curl
      data_table
      dbplyr
      digest
      dplyr
      dtplyr
      ellipsis
      evaluate
      fansi
      farver
      fastmap
      forcats
      fs
      gargle
      generics
      ggplot2
      glue
      googledrive
      googlesheets4
      gridExtra
      gtable
      haven
      highr
      hms
      htmltools
      httr
      ids
      isoband
      jquerylib
      jsonlite
      kableExtra
      knitr
      labeling
      latex2exp
      lattice
      lifecycle
      lubridate
      magrittr
      mgcv
      mime
      modelr
      munsell
      nlme
      openssl
      pillar
      pkgconfig
      prettyunits
      processx
      progress
      ps
      purrr
      rappdirs
      readr
      readxl
      rematch
      rematch2
      renv
      reprex
      rjags
      rlang
      rmarkdown
      rstudioapi
      rvest
      sass
      scales
      selectr
      stringi
      stringr
      svglite
      sys
      systemfonts
      tibble
      tidyr
      tidyselect
      tidyverse
      tinytex
      tzdb
      utf8
      uuid
      vctrs
      viridisLite
      vroom
      webshot
      withr
      xfun
      xml2
      yaml;
  };
    
  system_packages = builtins.attrValues {
    inherit (pkgs) 
      quarto
      R
      glibcLocales
      nix;
  };
 
  wrapped_pkgs = pkgs.rstudioWrapper.override {
    packages = [  rpkgs  ];
  };
 
in

pkgs.mkShell {
  LOCALE_ARCHIVE = if pkgs.system == "x86_64-linux" then  "${pkgs.glibcLocales}/lib/locale/locale-archive" else "";
  LANG = "en_US.UTF-8";
   LC_ALL = "en_US.UTF-8";
   LC_TIME = "en_US.UTF-8";
   LC_MONETARY = "en_US.UTF-8";
   LC_PAPER = "en_US.UTF-8";
   LC_MEASUREMENT = "en_US.UTF-8";

  buildInputs = [  rpkgs  system_packages  wrapped_pkgs ];
  
}

### Bootstrapping isolated, project-specific, and runtime-pure R setup via Nix ###

==> Existing isolated nix-R project folder:
 /tmp/published-202312-favrot-hierarchical 

* current R session running outside Nix environment and not from RStudio

==> Added `.Rprofile` file and code lines for new R sessions launched from:
/tmp/published-202312-favrot-hierarchical

* Added the location of the Nix store to `PATH` environmental variable for new R sessions on host/docker RStudio:
/nix/var/nix/profiles/default/bin

==> Also adjusting `PATH` via `Sys.setenv()`, so that system commands can invoke key Nix commands like `nix-build` in this RStudio session outside Nix


### Successfully generated `default.nix` and `.Rprofile` ###

Note that the above triggers the following warning because an .Rprofile``` file already exists. In this case this file is only used byrenvand we will not needrenv` so we do not follow the advice to ‘append’ and instead choose to ‘overwrite’:

library("rix")
path_default_nix <- "/tmp/published-202312-favrot-hierarchical"
rix_init(rprofile_action = 'overwrite', project_path = path_default_nix)
# ### Bootstrapping isolated, project-specific, and runtime-pure R setup via Nix ###
# ==> Existing isolated nix-R project folder:
#  /tmp/published-202312-favrot-hierarchical 
# 
# * current R session running outside Nix environment and not from RStudio
# 
# ==> Overwrote `.Rprofile` file and code lines for new R sessions launched from:
# /tmp/published-202312-favrot-hierarchical
# 
# * Added the location of the Nix store to `PATH` environmental variable for new R sessions on host/docker RStudio:
# /nix/var/nix/profiles/default/bin> 

We are now ready to build and launch the corresponding Nix environment:

nix-build 
nix-shell

And to try to render the publication:

[nix-shell:/tmp/published-202312-favrot-hierarchical]$quarto render

Unfortunately codetools is needed (why??) and was not specified in the renv.lock file, so it is missing and compilation fails:

Quitting from lines 343-346 (published-202312-favrot-hierarchical.qmd) 
Error in loadNamespace(x) : there is no package called 'codetools'
Calls: .main ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart

Execution halted

Note that it is not possible to install packages directly from within Nix

> install.packages("codetools")
Error in install.packages("codetools") : 
  You are currently in an R session running from Nix.
Don't install packages using install.packages(),
add them to the default.nix file instead.

So we go back to the configuration of our Nix environment:

info <- readRDS("repro_favrot.rds")
R_version <- info[["version"]]
pkgs <- info[["pkgs"]]
library(rix)
path_default_nix <- "/tmp/published-202312-favrot-hierarchical"
rix_init(rprofile_action = 'overwrite', project_path = path_default_nix)

### Bootstrapping isolated, project-specific, and runtime-pure R setup via Nix ###

==> Existing isolated nix-R project folder:
 /tmp/published-202312-favrot-hierarchical 

* current R session running outside Nix environment and not from RStudio

==> Overwrote `.Rprofile` file and code lines for new R sessions launched from:
/tmp/published-202312-favrot-hierarchical

* Added the location of the Nix store to `PATH` environmental variable for new R sessions on host/docker RStudio:
/nix/var/nix/profiles/default/bin
rix(
  r_ver = R_version,
  r_pkgs = c(pkgs, "codetools"),
  system_pkgs = NULL,
  git_pkgs = NULL,
  ide = "rstudio",
  project_path = path_default_nix,
  overwrite = TRUE,
  print = TRUE
)
# This file was generated by the {rix} R package v0.9.1 on 2024-09-12
# with following call:
# >rix(r_ver = "8ad5e8132c5dcf977e308e7bf5517cc6cc0bf7d8",
#  > r_pkgs = c(pkgs,
#  > "codetools"),
#  > system_pkgs = NULL,
#  > git_pkgs = NULL,
#  > ide = "rstudio",
#  > project_path = path_default_nix,
#  > overwrite = TRUE,
#  > print = TRUE)
# It uses nixpkgs' revision 8ad5e8132c5dcf977e308e7bf5517cc6cc0bf7d8 for reproducibility purposes
# which will install R version 4.2.2.
# Report any issues to https://github.com/b-rodrigues/rix
let
 pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/8ad5e8132c5dcf977e308e7bf5517cc6cc0bf7d8.tar.gz") {};
 
  rpkgs = builtins.attrValues {
    inherit (pkgs.rPackages) 
      DBI
      MASS
      Matrix
      R6
      RColorBrewer
      askpass
      assertthat
      backports
      base64enc
      bit
      bit64
      blob
      broom
      bslib
      callr
      cellranger
      cli
      clipr
      coda
      colorspace
      cowplot
      cpp11
      crayon
      curl
      data_table
      dbplyr
      digest
      dplyr
      dtplyr
      ellipsis
      evaluate
      fansi
      farver
      fastmap
      forcats
      fs
      gargle
      generics
      ggplot2
      glue
      googledrive
      googlesheets4
      gridExtra
      gtable
      haven
      highr
      hms
      htmltools
      httr
      ids
      isoband
      jquerylib
      jsonlite
      kableExtra
      knitr
      labeling
      latex2exp
      lattice
      lifecycle
      lubridate
      magrittr
      mgcv
      mime
      modelr
      munsell
      nlme
      openssl
      pillar
      pkgconfig
      prettyunits
      processx
      progress
      ps
      purrr
      rappdirs
      readr
      readxl
      rematch
      rematch2
      renv
      reprex
      rjags
      rlang
      rmarkdown
      rstudioapi
      rvest
      sass
      scales
      selectr
      stringi
      stringr
      svglite
      sys
      systemfonts
      tibble
      tidyr
      tidyselect
      tidyverse
      tinytex
      tzdb
      utf8
      uuid
      vctrs
      viridisLite
      vroom
      webshot
      withr
      xfun
      xml2
      yaml
      codetools;
  };
    
  system_packages = builtins.attrValues {
    inherit (pkgs) 
      R
      glibcLocales
      nix;
  };
 
  wrapped_pkgs = pkgs.rstudioWrapper.override {
    packages = [  rpkgs  ];
  };
 
in

pkgs.mkShell {
  LOCALE_ARCHIVE = if pkgs.system == "x86_64-linux" then  "${pkgs.glibcLocales}/lib/locale/locale-archive" else "";
  LANG = "en_US.UTF-8";
   LC_ALL = "en_US.UTF-8";
   LC_TIME = "en_US.UTF-8";
   LC_MONETARY = "en_US.UTF-8";
   LC_PAPER = "en_US.UTF-8";
   LC_MEASUREMENT = "en_US.UTF-8";

  buildInputs = [  rpkgs  system_packages  wrapped_pkgs ];
  
}


### Successfully generated `default.nix` in /tmp/published-202312-favrot-hierarchical. Keeping `.Rprofile` generated by `rix::rix_init()`###

and rebuild and restart the environment (fortunately the build is very fast because it only takes the missing package to be installed):

nix-build
nix-shell
[nix-shell:/tmp/published-202312-favrot-hierarchical]$ quarto render

… and this is a victory!

Output created: _site/published-202312-favrot-hierarchical.html

References

Favrot, Armand, and David Makowski. 2024. “A Hierarchical Model to Evaluate Pest Treatments from Prevalence and Intensity Data.” Computo, January. https://doi.org/10.57750/6cgk-g727.