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

snapshot() fails with error message Error in if (package == "R") return() : missing value where TRUE/FALSE needed #2073

Closed
jrisi256 opened this issue Jan 9, 2025 · 5 comments

Comments

@jrisi256
Copy link

jrisi256 commented Jan 9, 2025

Hi,

When I try to run renv::snapshot(), it fails with the following error/warning message:

Error in if (package == "R") return() : 
  missing value where TRUE/FALSE needed
In addition: Warning message:
In parse(text = text, keep.source = FALSE, srcfile = NULL)[[1L]] :
  subscript out of bounds

The diagnostics are below. If I can provide more information, please let me know! Thanks for making such a great package.

> renv::diagnostics()
Diagnostics Report [renv 1.0.11]
================================

# /etc/lsb-release -----------------------------------------------------------
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.5 LTS"

# /etc/os-release ------------------------------------------------------------
PRETTY_NAME="Ubuntu 22.04.5 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.5 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy


# Session Info ---------------------------------------------------------------
R version 4.2.2 (2022-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.5 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
[1] renv_1.0.11

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.13-1     rstudioapi_0.17.1 magrittr_2.0.3    usethis_3.1.0    
 [5] devtools_2.4.5    pkgload_1.4.0     xtable_1.8-4      R6_2.5.1         
 [9] rlang_1.1.4       fastmap_1.2.0     urlchecker_1.0.1  tools_4.2.2      
[13] pkgbuild_1.4.5    sessioninfo_1.2.2 miniUI_0.1.1.1    cli_3.6.3        
[17] remotes_2.5.0     htmltools_0.5.8.1 ellipsis_0.3.2    yaml_2.3.10      
[21] digest_0.6.37     lifecycle_1.0.4   brio_1.1.5        shiny_1.10.0     
[25] purrr_1.0.2       later_1.4.1       vctrs_0.6.5       htmlwidgets_1.6.4
[29] profvis_0.4.0     fs_1.6.5          promises_1.3.2    testthat_3.2.2   
[33] glue_1.8.0        memoise_2.0.1     cachem_1.1.0      mime_0.12        
[37] compiler_4.2.2    httpuv_1.6.15    

# Project --------------------------------------------------------------------
Project path: "~/Documents/secret_lives_pa"

# Status ---------------------------------------------------------------------
The following package(s) are in an inconsistent state:

 package  installed recorded used
 ellipsis y         y        n   

The following package(s) are out of sync [lockfile != library]:

# CRAN -----------------------------------------------------------------------
- askpass       [1.2.0 != 1.2.1]
- bit           [4.0.5 != 4.5.0.1]
- bit64         [4.0.5 != 4.5.2]
- bitops        [1.0-7 != 1.0-9]
- bslib         [0.6.1 != 0.8.0]
- cachem        [1.0.8 != 1.1.0]
- caTools       [1.18.2 != 1.18.3]
- cli           [3.6.2 != 3.6.3]
- cpp11         [0.4.7 != 0.5.1]
- crayon        [1.5.2 != 1.5.3]
- curl          [5.2.0 != 6.1.0]
- data.table    [1.15.4 != 1.16.4]
- digest        [0.6.34 != 0.6.37]
- evaluate      [1.0.0 != 1.0.1]
- fastmap       [1.1.1 != 1.2.0]
- fontawesome   [0.5.2 != 0.5.3]
- fs            [1.6.3 != 1.6.5]
- glue          [1.7.0 != 1.8.0]
- gtable        [repo: RSPM != CRAN; ver: 0.3.5 != 0.3.6]
- htmltools     [0.5.7 != 0.5.8.1]
- jsonlite      [1.8.8 != 1.8.9]
- knitr         [repo: RSPM != CRAN; ver: 1.48 != 1.49]
- lattice       [0.20-45 != 0.22-6]
- lubridate     [1.9.3 != 1.9.4]
- mgcv          [1.8-41 != 1.9-1]
- nlme          [3.1-162 != 3.1-166]
- openssl       [2.1.1 != 2.3.0]
- pillar        [1.9.0 != 1.10.1]
- processx      [3.8.3 != 3.8.5]
- ps            [1.7.6 != 1.8.1]
- R.oo          [1.26.0 != 1.27.0]
- Rcpp          [1.0.12 != 1.0.13-1]
- rlang         [1.1.3 != 1.1.4]
- rmarkdown     [2.28 != 2.29]
- rvest         [1.0.3 != 1.0.4]
- sass          [0.4.8 != 0.4.9]
- stringi       [1.8.3 != 1.8.4]
- sys           [3.4.2 != 3.4.3]
- tidyselect    [1.2.0 != 1.2.1]
- tinytex       [0.53 != 0.54]
- withr         [3.0.0 != 3.0.2]
- xfun          [0.47 != 0.50]
- yaml          [2.3.8 != 2.3.10]

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

# Packages -------------------------------------------------------------------
Traceback (most recent calls last):
4: renv::diagnostics()
3: tryCatch(reporter(project), error = renv_error_handler) at diagnostics.R#47
2: tryCatchList(expr, classes, parentenv, handlers)
1: tryCatchOne(expr, names, parentenv, handlers[[1L]])

# ABI ------------------------------------------------------------------------
- No ABI problems were detected in the set of installed packages.

# User Profile ---------------------------------------------------------------
[no user profile detected]

# Settings -------------------------------------------------------------------
List of 13
 $ bioconductor.version     : NULL
 $ external.libraries       : chr(0) 
 $ ignored.packages         : chr(0) 
 $ package.dependency.fields: chr [1:3] "Imports" "Depends" "LinkingTo"
 $ ppm.enabled              : NULL
 $ ppm.ignored.urls         : NULL
 $ r.version                : NULL
 $ snapshot.type            : chr "implicit"
 $ use.cache                : logi TRUE
 $ vcs.ignore.cellar        : logi TRUE
 $ vcs.ignore.library       : logi TRUE
 $ vcs.ignore.local         : logi TRUE
 $ vcs.manage.ignores       : logi TRUE

# Options --------------------------------------------------------------------
List of 9
 $ defaultPackages                     : chr [1:6] "datasets" "utils" "grDevices" "graphics" ...
 $ download.file.method                : chr "libcurl"
 $ download.file.extra                 : NULL
 $ install.packages.compile.from.source: NULL
 $ pkgType                             : chr "source"
 $ repos                               : Named chr "https://cloud.r-project.org"
  ..- attr(*, "names")= chr "CRAN"
 $ renv.consent                        : logi TRUE
 $ renv.config.updates.parallel        : logi TRUE
 $ renv.verbose                        : logi TRUE

# Environment Variables ------------------------------------------------------
HOME                        = /home/joe
LANG                        = en_US.UTF-8
MAKE                        = make
R_LIBS                      = <NA>
R_LIBS_SITE                 = /opt/R/4.2.2/lib/R/site-library
R_LIBS_USER                 = /home/joe/Documents/secret_lives_pa/renv/library/R-4.2/x86_64-pc-linux-gnu
RENV_DEFAULT_R_ENVIRON      = <NA>
RENV_DEFAULT_R_ENVIRON_USER = <NA>
RENV_DEFAULT_R_LIBS         = <NA>
RENV_DEFAULT_R_LIBS_SITE    = /opt/R/4.2.2/lib/R/site-library
RENV_DEFAULT_R_LIBS_USER    = /home/joe/R/x86_64-pc-linux-gnu-library/4.2
RENV_DEFAULT_R_PROFILE      = <NA>
RENV_DEFAULT_R_PROFILE_USER = <NA>
RENV_PROJECT                = /home/joe/Documents/secret_lives_pa

# PATH -----------------------------------------------------------------------
- /home/joe/Documents/secret_lives_pa/secret_lives_pa_virtenv/bin
- /home/joe/.local/bin
- /opt/python/3.11.0/bin
- /usr/local/sbin
- /usr/local/bin
- /usr/sbin
- /usr/bin
- /sbin
- /bin
- /usr/games
- /usr/local/games
- /snap/bin
- /usr/lib/rstudio/resources/app/bin/quarto/bin
- /usr/lib/rstudio/resources/app/bin/postback

# Cache ----------------------------------------------------------------------
There are a total of 599 packages installed in the renv cache.
Cache path: "~/.cache/R/renv/cache/v5/R-4.2/x86_64-pc-linux-gnu"

Warning messages:
1: In parse(text = text, keep.source = FALSE, srcfile = NULL)[[1L]] :
  subscript out of bounds
2: In parse(text = text, keep.source = FALSE, srcfile = NULL)[[1L]] :
  subscript out of bounds
@kevinushey
Copy link
Collaborator

Thanks for the bug report -- is there any chance you can share a reproducible example, or share the project where you're encountering this issue?

@kevinushey
Copy link
Collaborator

It might also help to try running with options(warn = 2) set, so that this warning:

In addition: Warning message:
In parse(text = text, keep.source = FALSE, srcfile = NULL)[[1L]] :
  subscript out of bounds

could be promoted to an error, and then we'll hopefully get a traceback.

@jrisi256
Copy link
Author

  1. https://github.com/jrisi256/secret_lives_pa --> The link to the project in question where I am experiencing the problems. It is odd because I am not experiencing this problem on my other projects. I tried downgrading to (many) different versions of renv, but none of the older versions worked either. I wish I knew when this problem first popped up. I am not sure what more of a reproducible example I could produce? I start up RStudio, and then the project loads with the following message: Warning message: In parse(text = text, keep.source = FALSE, srcfile = NULL)[[1L]] :subscript out of bounds. Then, I try and run renv::snapshot() to save the changes made to my lockfile, and then the above error happens.

  2. Other steps I tried to fix the problem --> I have run renv::clean(), renv::rebuild(), renv::refresh(), renv::repair(), renv::update(), renv::upgrade(), and renv::deactivate() (and then subsequently re-activating the project). After running these, the problem still remained.

  3. Interestingly, I also cannot run renv::scaffold() or renv::init() (when choosing the 2nd option to discard the lockfile). They both produce the original error message.

  4. When I set options(warn = 2) and then run renv::snapshot() this is the following traceback I get:

23.
doWithOneRestart(return(expr), restart)
22.
withOneRestart(expr, restarts[[1L]])
21.
withRestarts({
.Internal(.signalCondition(cond, message, call))
.Internal(.dfltWarn(message, call))
}, muffleWarning = function() NULL)
20.
warning(cnd) at utils.R#589
19.
warnify(status) at dependencies.R#501
18.
signalCondition(warnify(status)) at dependencies.R#501
17.
FUN(X[[i]], ...)
16.
lapply(x, f, ...) at utils-map.R#3
15.
bapply(paths, renv_dependencies_discover_impl) at dependencies.R#476
14.
renv_dependencies_discover(files, progress, errors) at dependencies.R#246
13.
renv_dependencies_impl(path = path, root = project, field = "Package",
errors = config$dependency.errors(), dev = dev) at snapshot.R#1012
12.
withCallingHandlers(renv_dependencies_impl(path = path, root = project,
field = "Package", errors = config$dependency.errors(), dev = dev),
renv.dependencies.problems = function(cnd) {
if (identical(config$dependency.errors(), "ignored")) ... at snapshot.R#1012
11.
renv_snapshot_dependencies_impl(project, type, dev) at snapshot.R#968
10.
the$dynamic_objects[[id]] %||% {
dlog("dynamic", "memoizing dynamic value for '%s'", id)
value
} at dynamic.R#57
9.
dynamic(list(project = project, type = type, dev = dev), renv_snapshot_dependencies_impl(project,
type, dev)) at snapshot.R#968
8.
renv_snapshot_dependencies(project = project, type = type, dev = dev) at lockfile.R#194
7.
packages %||% renv_snapshot_dependencies(project = project, type = type,
dev = dev) at lockfile.R#194
6.
renv_lockfile_create_impl(project, type, libpaths, packages,
exclude, prompt, force, dev = dev) at lockfile.R#180
5.
doWithOneRestart(return(expr), restart)
4.
withOneRestart(expr, restarts[[1L]])
3.
withRestarts(renv_lockfile_create_impl(project, type, libpaths,
packages, exclude, prompt, force, dev = dev), renv_recompute_records = function() {
renv_dynamic_reset()
renv_lockfile_create_impl(project, type, libpaths, packages, ... at lockfile.R#180
2.
renv_lockfile_create(project = project, type = type, libpaths = libpaths,
packages = packages, exclude = exclude, prompt = prompt,
force = force, dev = dev) at snapshot.R#176
1.
renv::snapshot()

@jrisi256
Copy link
Author

jrisi256 commented Jan 10, 2025

Well, I figured out the issue.

https://github.com/jrisi256/secret_lives_pa/blob/main/pdf_parsing/src/dockets/test_extraction_code.ipynb

When I remove this file, renv::snapshot() works well. A collaborator must have made this file because I do not recognize it. It seems like an empty .ipynb file? Do you know why this would be causing renv to crash? I will hold off on pushing my changes to the project so you can see the file for yourself.

@kevinushey
Copy link
Collaborator

Aha, thanks!

renv also attempts to parse R package dependencies from .ipynb files within a project, but is evidently having trouble with empty / invalid files in this scenario. I'll get this fixed up; I appreciate your taking the time to find the underlying cause!

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

2 participants