carpentries / workbench

Repository for Discussions and Materials about The Carpentries Workbench
https://carpentries.github.io/workbench/
Creative Commons Attribution 4.0 International
17 stars 7 forks source link

R Lessons: document how to run update_cache() when there is a package conflict #40

Open zkamvar opened 1 year ago

zkamvar commented 1 year ago

I recently ran into this fun thing, I am trying to make the release for the beta phase repositories and I was trying to build the R Raster lesson and ran into this fun error status when resolving the dependencies:

── managing R dependencies ──

ℹ Consent to use package cache provided
→ Searching for and installing available dependencies
Finding R package dependencies ... Done!
* Discovering package dependencies ... Done!
* Copying packages into the cache ... Done!
→ Restoring any dependency versions
The following package(s) will be updated:

# CRAN ===============================
- cli         [3.6.0 -> 3.5.0]
- evaluate    [0.20 -> 0.19]
- rmarkdown   [2.20 -> 2.19]
- tinytex     [0.44 -> 0.43]
- xfun        [0.37 -> 0.36]
- yaml        [2.3.7 -> 2.3.6]

# RSPM ===============================
- fs          [repo: CRAN -> RSPM; ver: 1.6.0 -> 1.5.2]
- knitr       [repo: CRAN -> RSPM; ver: 1.42 -> 1.41]
- sass        [repo: CRAN -> RSPM; ver: 0.4.5 -> 0.4.4]
- vctrs       [repo: CRAN -> RSPM; ver: 0.5.2 -> 0.5.1]
- renv        [* -> 0.16.0]

# https://carpentries.r-universe.dev =
- stringi     [repo: CRAN -> https://carpentries.r-universe.dev; ver: 1.7.12 -> 1.7.10; ref: * -> v1.7.10; sha: * -> 8558da46]

Installing cli [3.5.0] ...
    OK [linked cache]
Installing evaluate [0.19] ...
    OK [linked cache]
Installing fs [1.5.2] ...
    OK [linked cache]
Installing xfun [0.36] ...
    OK [linked cache]
Installing stringi [1.7.10] ...
    OK [linked cache]
Installing vctrs [0.5.1] ...
    OK [linked cache]
Installing yaml [2.3.6] ...
    OK [linked cache]
Installing knitr [1.41] ...
    OK [linked cache]
Installing sass [0.4.4] ...
    OK [linked cache]
Installing tinytex [0.43] ...
    OK [linked cache]
Installing rmarkdown [2.19] ...
    OK [linked cache]
Installing renv [0.16.0] ...
    OK [linked cache]
The following package(s) have been updated:

    cli  [installed version 3.5.0 != loaded version 3.6.0]
    yaml [installed version 2.3.6 != loaded version 2.3.7]

Consider restarting the R session and loading the newly-installed packages.

→ Recording changes in lockfile
The following package(s) have unsatisfied dependencies:

    tidyr requires vctrs (>= 0.5.2), but version 0.5.1 is installed
    dplyr requires vctrs (>= 0.5.2), but version 0.5.1 is installed

Consider updating the required dependencies as appropriate.

Error: 
! in callr subprocess.
Caused by error in `renv::snapshot(project = path, lockfile = renv_lock, prompt = FALSE)`:
! aborting snapshot due to pre-flight validation failure

Cause of the problem

The cause was due to an update in a package (dplyr and tidyr) requiring a new version of a dependency and, what I am assuming is, a race condition for updating the dependencies from the cache.

Solution

The solution is to update the cache before running the manage dependencies, which is achieved either through sandpaper::update_cache() or manually running the 03 Maintain: Update Cache workflow as shown here: https://github.com/carpentries/workbench-template-rmd/pull/31

zkamvar commented 1 year ago

Note: I believe this is ONLY a problem when creating a lesson from an outdated template. I do not believe this is a problem for existing lessons

sarahkaspar commented 1 year ago

Hi, I get the same error status, but updating the cache did not resolve it in my case. I created the lesson from the template in Dec22. Do you have any other ideas, except transferring the episodes to a new repository?

zkamvar commented 1 year ago

Hi Sarah,

Thank you for reporting this and I'm sorry for the trouble. I will take a look at your lesson (https://github.com/sarahkaspar/biostatistics-course) today and see what I can do to help.

One thing I see is that you have a renv folder inside of the episodes/ directory that I think might be interfering with the process: https://github.com/sarahkaspar/biostatistics-course/tree/main/episodes/renv. (edit: this episodes/renv folder is caused by a bug in sandpaper: https://github.com/carpentries/sandpaper/issues/391)

sarahkaspar commented 1 year ago

Thank you for your help Zhian!

zkamvar commented 1 year ago

No problem! Thank you again for reporting on the issue! I cannot stress enough how much finding these little bugs will help so many people down the line.