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

settings.json file with empty r.version causes failure #1353

Closed
zkamvar opened this issue May 26, 2023 · 3 comments
Closed

settings.json file with empty r.version causes failure #1353

zkamvar opened this issue May 26, 2023 · 3 comments

Comments

@zkamvar
Copy link
Contributor

zkamvar commented May 26, 2023

Once again, I am finding myself caught in a situation where something has changed and I do not know what it is. Here is a reprex (that uses the packages for {knitr}), but I will work on producing a minimal one:

remotes::install_github("rstudio/renv@43ab2f25bef0c53e544126723312618fb547929a")
install.packages(c("sandpaper", "varnish"), repos = c("https://carpentries.r-universe.dev", "https://cran.rstudio.com"))

usethis::create_from_github("carpentries/sandpaper-docs")
sandpaper::build_lesson()
reprex output
> usethis::create_from_github("carpentries/sandpaper-docs")                                                                                                                   
✔ Setting `fork = FALSE`Creating '/home/zhian/Desktop/sandpaper-docs/'Cloning repo from 'https://github.com/carpentries/sandpaper-docs.git' into '/home/zhian/Desktop/sandpaper-docs'Setting active project to '/home/zhian/Desktop/sandpaper-docs'Default branch is 'main'

> sandpaper::build_lesson()                                                                                                                                                   
── Validating Fenced Divs ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
── Validating Internal Links and Images ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
! There were errors in 1/149 linksSome linked internal files do not exist

episodes/episodes.Rmd:767 [missing file]: [Example of Wrapped Alt Text (with apologies to William Carlos Williams)](fig/freezer.png)
ℹ Consent to use package cache providedSearching for and installing available dependencies
Done!ng R package dependencies ... 
Done!covering package dependencies ... 
The following packages were discovered:

# ~/R/library ========================
- base64enc     0.1-3
- bslib         0.4.2
- cachem        1.0.8
- cli           3.6.1
- digest        0.6.31
- ellipsis      0.3.2
- evaluate      0.21
- fastmap       1.1.1
- fontawesome   0.5.1
- fs            1.6.2
- glue          1.6.2
- highr         0.10
- htmltools     0.5.5
- jquerylib     0.1.4
- jsonlite      1.8.4
- knitr         1.42
- lifecycle     1.0.3
- magrittr      2.0.3
- memoise       2.0.1
- mime          0.12
- R6            2.5.1
- rappdirs      0.3.3
- rlang         1.1.1
- rmarkdown     2.21
- sass          0.4.6
- stringi       1.7.12
- stringr       1.5.0
- tinytex       0.45
- vctrs         0.6.2
- xfun          0.39
- yaml          2.3.7

They will be linked into the project library.

Done!king packages into the project library ... 
* Hydrated 31 packages in 71 milliseconds.Restoring any dependency versions
The following package(s) will be updated:

# CRAN ===============================
- renv       [* -> 0.17.3]

# RSPM ===============================
- evaluate   [repo: CRAN -> RSPM; ver: 0.21 -> 0.20]
- sass       [repo: CRAN -> RSPM; ver: 0.4.6 -> 0.4.5]

Installing sass [0.4.5] ...
|       OK [linked cache in 0.28 milliseconds]
Installing evaluate [0.20] ...
-       OK [linked cache in 0.27 milliseconds]
Installing renv [0.17.3] ...
|       OK [linked cache in 0.31 milliseconds]
The following package(s) have been updated:

	renv [installed version 0.17.3 != loaded version 0.17.3-72]

Consider restarting the R session and loading the newly-installed packages.Recording changes in lockfile
The version of R recorded in the lockfile will be updated:

* Lockfile written to '~/Desktop/sandpaper-docs/renv/profiles/lesson-requirements/renv.lock'.Using package cache in /home/zhian/.cache/R/renv
Error: 
! in callr subprocess.
Caused by error in `unclass(numeric_version(version))[[1]]`:
! subscript out of bounds
Type .Last.error to see the more details.
Session Information
─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.3.0 (2023-04-21)
 os       Ubuntu 20.04.6 LTS
 system   x86_64, linux-gnu
 ui       X11
 language en_US:en
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       America/Los_Angeles
 date     2023-05-26
 pandoc   2.12 @ /home/zhian/anaconda3/bin/ (via rmarkdown)

─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 package     * version   date (UTC) lib source
 askpass       1.1       2019-01-13 [1] CRAN (R 4.0.0)
 assertthat    0.2.1     2019-03-21 [1] CRAN (R 4.0.0)
 callr         3.7.3     2022-11-02 [1] RSPM (R 4.2.0)
 cli           3.6.1     2023-03-23 [1] RSPM (R 4.2.0)
 commonmark    1.9.0     2023-03-17 [1] RSPM (R 4.2.0)
 credentials   1.3.2     2021-11-29 [1] CRAN (R 4.1.2)
 digest        0.6.31    2022-12-11 [1] RSPM (R 4.2.0)
 dplyr         1.1.2     2023-04-20 [1] RSPM (R 4.3.0)
 evaluate      0.21      2023-05-05 [1] RSPM (R 4.3.0)
 fansi         1.0.4     2023-01-22 [1] RSPM (R 4.2.0)
 fastmap       1.1.1     2023-02-24 [1] RSPM (R 4.2.0)
 fs            1.6.2     2023-04-25 [1] RSPM (R 4.3.0)
 generics      0.1.3     2022-07-05 [1] RSPM (R 4.2.0)
 gert          1.9.2     2022-12-05 [1] RSPM (R 4.2.0)
 glue          1.6.2     2022-02-24 [1] RSPM (R 4.2.0)
 htmltools     0.5.5     2023-03-23 [1] RSPM (R 4.2.0)
 knitr         1.42      2023-01-25 [1] CRAN (R 4.2.2)
 lifecycle     1.0.3     2022-10-07 [1] CRAN (R 4.2.1)
 magrittr      2.0.3     2022-03-30 [1] CRAN (R 4.1.3)
 openssl       2.0.6     2023-03-09 [1] RSPM (R 4.2.0)
 pegboard      0.5.3     2023-05-19 [1] Github (carpentries/pegboard@3b06f45)
 pillar        1.9.0     2023-03-22 [1] RSPM (R 4.2.0)
 pkgconfig     2.0.3     2019-09-22 [1] CRAN (R 4.0.4)
 processx      3.8.1     2023-04-18 [1] RSPM (R 4.3.0)
 ps            1.7.5     2023-04-18 [1] RSPM (R 4.3.0)
 purrr         1.0.1     2023-01-10 [1] RSPM (R 4.2.0)
 R6            2.5.1     2021-08-19 [1] CRAN (R 4.1.1)
 Rcpp          1.0.10    2023-01-22 [1] RSPM (R 4.2.0)
 renv          0.17.3-72 2023-05-26 [1] Github (rstudio/renv@43ab2f2)
 rlang         1.1.1     2023-04-28 [1] RSPM (R 4.3.0)
 rmarkdown     2.21      2023-03-26 [1] RSPM (R 4.2.0)
 rprojroot     2.0.3     2022-04-02 [1] CRAN (R 4.1.3)
 sandpaper   * 0.12.0    2023-05-24 [1] https://carpentries.r-universe.dev (R 4.3.0)
 sessioninfo   1.2.2     2021-12-06 [1] CRAN (R 4.1.2)
 sys           3.4.2     2023-05-23 [1] CRAN (R 4.3.0)
 tibble        3.2.1     2023-03-20 [1] RSPM (R 4.2.0)
 tidyselect    1.2.0     2022-10-10 [1] RSPM (R 4.2.0)
 tinkr         0.2.0     2023-05-19 [1] Github (ropensci/tinkr@a5dd3dd)
 utf8          1.2.3     2023-01-31 [1] RSPM (R 4.2.0)
 vctrs         0.6.2     2023-04-19 [1] RSPM (R 4.3.0)
 whisker       0.4.1     2022-12-05 [1] RSPM (R 4.2.0)
 xfun          0.39      2023-04-20 [1] RSPM (R 4.3.0)
 xml2          1.3.4     2023-04-27 [1] RSPM (R 4.3.0)
 xslt          1.4.4     2023-02-21 [1] RSPM (R 4.2.0)
 yaml          2.3.7     2023-01-23 [1] RSPM (R 4.2.0)

 [1] /home/zhian/R/library
 [2] /usr/local/lib/R/site-library
 [3] /usr/lib/R/site-library
 [4] /usr/lib/R/library

────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

And here is the trackeback of the error, but this points to the fact that {renv} is trying to load a project that has no R version attached.

<callr_error/rlib_error_3_0/rlib_error/error>
Error: 
! in callr subprocess.
Caused by error in `unclass(numeric_version(version))[[1]]`:
! subscript out of bounds
---
Backtrace:
1. sandpaper::build_lesson()
2. sandpaper:::build_markdown(path = path, rebuild = rebuild, quiet = quiet, …
3. sandpaper::build_episode_md(path = build_me[i], outdir = outdir, workdir = outdir, …
4. callr::r(func = callr_build_episode_md, args = args, show = !quiet, …
5. callr:::get_result(output = out, options)
6. callr:::throw(callr_remote_error(remerr, output), parent = fix_msg(remerr[[3]]))
---
Subprocess backtrace:
1. renv::load(root)
2. renv:::renv_load_r(project, lockfile$R)
3. global (function (e) …

The diff for the lockfile looks like this:

 {
   "R": {
-    "Version": "4.3.0",
+    "Version": [],
     "Repositories": [
       {
         "Name": "carpentries",
@@ -256,6 +256,12 @@
       "Version": "0.12",
       "Source": "Repository",
       "Repository": "RSPM",
+      "RemoteType": "standard",
+      "RemotePkgRef": "mime",
+      "RemoteRef": "mime",
+      "RemoteRepos": "https://cran.rstudio.com",
+      "RemotePkgPlatform": "source",
+      "RemoteSha": "0.12",
       "Requirements": [
         "tools"
       ],
@@ -335,17 +341,13 @@
       "Version": "1.7.12",
       "Source": "Repository",
       "Repository": "RSPM",
-      "RemoteType": "repository",
-      "RemoteUrl": "https://github.com/gagolews/stringi",
-      "RemoteRef": "v1.7.12",
-      "RemoteSha": "e4cf3176bc3943e6c477885be3445cbbd7d4bab6",
       "Requirements": [
         "R",
         "stats",
         "tools",
         "utils"
       ],
-      "Hash": "832ef2a01603f8f5b4f2af024080d5d9"
+      "Hash": "ca8bd84263c77310739d2cf64d84d7c9"
     },
     "stringr": {
       "Package": "stringr",
@kevinushey
Copy link
Collaborator

My guess is the project contains an renv/settings.json file which contains:

"r.version": []

Are you explicitly calling renv::settings$r.version() anywhere, or doing anything else to try and set a default R version?

@zkamvar zkamvar changed the title (working on minimal reprex) snapshot is clobbering R version in existing profile-based lockfiles settings.json file with empty r.version causes failure May 26, 2023
@zkamvar
Copy link
Contributor Author

zkamvar commented May 26, 2023

Are you explicitly calling renv::settings$r.version() anywhere, or doing anything else to try and set a default R version?

Not at all. We use a hydrate -> restore -> snapshot workflow

You are correct that the project contains a renv/profiles/lesson-requirements/renv/settings.json with an empty R version, which was added in carpentries/sandpaper-docs@b9ec78a.

I believe it's a holdover from when I first created the {renv} project back in January 2022, which created the settings.dcf file.

I've taken a look at some of the more recent repositories. They do not have the settings (i.e. datacarpentry/r-socialsci), and yet they work with this version of {renv} so I believe this will be fixed if I remove the settings files.

@kevinushey
Copy link
Collaborator

Thanks! I also pushed a bandaid to renv here: 6014f8d

@hadley hadley closed this as completed May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants