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

renv::snapshot() fails for 1.0.10 version on Windows if run on a package directory that has an exported function called module() #2007

Closed
m7pr opened this issue Oct 8, 2024 · 2 comments

Comments

@m7pr
Copy link

m7pr commented Oct 8, 2024

Thanks for creating renv! This is super useful mechanism that we used in many projects!
We appreciate the time and the energy you invested in building the tool.

ver 1.0.10 issue

Recently we noticed some weird behavior for the newly released renv 1.1.0 on Windows.
If you have an exported function called module and it's used in testthat tests,
then when running renv::snapshot() you can see it fails to create the lockfile.

The reproducible example can be based on this repository https://github.com/m7pr/renv.modules
Just pull it and run renv::snapshot().

That's what I get

> renv::snapshot()
Error in if (package == "R") return() : 
  missing value where TRUE/FALSE needed
In addition: Warning message:
In node[[2L]] : subscript out of bounds
> renv::dependencies()$traceback
Finding R package dependencies ... Done!
 [1] NA                                                                    
 [2] "21: renv::dependencies()"                                            
 [3] "20: renv_dependencies_impl(path = path, root = root, quiet = quiet, "
 [4] "19: renv_dependencies_discover(files, progress, errors)"             
 [5] "15: catch(filebacked(\"dependencies\", path, callback))"             
 [6] "14: tryCatch(withCallingHandlers(expr, error = renv_error_capture), "
 [7] "13: tryCatchList(expr, classes, parentenv, handlers)"                
 [8] " 9: filebacked(\"dependencies\", path, callback)"                    
 [9] " 8: callback(path, ...)"                                             
[10] " 6: renv_dependencies_recurse(expr, function(node) {"                
[11] "        invisible(node)"                                             
[12] "    })"                                                              
[13] " 4: renv_dependencies_recurse_impl(object[[i]], callback)"           
[14] NA                                                                    
[15] NA                                                                    
Warning message:
In node[[2L]] : subscript out of bounds
> sessionInfo()
R version 4.4.0 (2024-04-24 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22621)

Matrix products: default


locale:
[1] LC_COLLATE=English_Europe.utf8  LC_CTYPE=English_Europe.utf8   
[3] LC_MONETARY=English_Europe.utf8 LC_NUMERIC=C                   
[5] LC_TIME=English_Europe.utf8    

time zone: Europe/Berlin
tzcode source: internal

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

other attached packages:
[1] renv.modules_0.1.0

loaded via a namespace (and not attached):
[1] compiler_4.4.0    cli_3.6.3         tools_4.4.0       rstudioapi_0.16.0
[5] renv_1.0.10  

ver 1.0.9 no issue

This does not happen on previous version

> remotes::install_github('rstudio/renv@v1.0.9')
> library(renv)
> packageVersion('renv')
[1] ‘1.0.9’
> renv::snapshot()
The following package(s) will be updated in the lockfile:
  
  # CRAN -----------------------------------------------------------------------
- brio        [* -> 1.1.5]
- callr       [* -> 3.7.6]
- crayon      [* -> 1.5.2]
- desc        [* -> 1.4.3]
- diffobj     [* -> 0.3.5]
- digest      [* -> 0.6.35]
- fansi       [* -> 1.0.6]
- fs          [* -> 1.6.4]
- glue        [* -> 1.7.0]
- jsonlite    [* -> 1.8.9]
- lifecycle   [* -> 1.0.4]
- magrittr    [* -> 2.0.3]
- pillar      [* -> 1.9.0]
- pkgbuild    [* -> 1.4.4]
- pkgconfig   [* -> 2.0.3]
- pkgload     [* -> 1.4.0]
- praise      [* -> 1.0.0]
- processx    [* -> 3.8.4]
- ps          [* -> 1.7.6]
- R6          [* -> 2.5.1]
- rematch2    [* -> 2.1.2]
- rlang       [* -> 1.1.4]
- rprojroot   [* -> 2.0.4]
- testthat    [* -> 3.2.1.1]
- tibble      [* -> 3.2.1]
- utf8        [* -> 1.2.4]
- vctrs       [* -> 0.6.5]
- waldo       [* -> 0.5.2]

# GitHub ---------------------------------------------------------------------
- renv        [ver: 1.0.10 -> 1.0.9; ref: v1.0.10 -> v1.0.9; sha: 0687c788 -> ed605b46]

# RSPM -----------------------------------------------------------------------
- evaluate    [* -> 1.0.0]
- withr       [* -> 3.0.1]

# https://packagemanager.posit.co/cran/latest --------------------------------
- cli         [* -> 3.6.3]

Do you want to proceed? [Y/n]: 



Potential places for the fix

Is it a names collision with modules::module that is used inside renv?
Is it some collision with reticulate/python modules?
Is module a reserved name that is omitted or treated differently by renv?

Note

Suprisingly if you call module function with some custom parameter (like x = 1) then this issue no longer appears and you can crate the lockfile.

image

But if there is no parameter provided, renv::snapshot fails.

image
@kevinushey
Copy link
Collaborator

Thanks for the bug report, and especially for taking the time to provide a reproducible example! This should now be fixed up in the development version of renv; I'll try to get a patch release onto CRAN soon.

@m7pr
Copy link
Author

m7pr commented Oct 9, 2024

Wow @kevinushey - thanks for the quick fix!

@m7pr m7pr changed the title renv::snapshot() fails for 1.1.0 version on Windows if run on a package directory that has an exported function called module() renv::snapshot() fails for 1.0.10 version on Windows if run on a package directory that has an exported function called module() Oct 22, 2024
m7pr added a commit to insightsengineering/teal that referenced this issue Oct 22, 2024
Since `renv` was released on CRAN on Oct 12
https://cran.r-project.org/web/packages/renv/index.html with the newest
fix for the bug that we reported in here
rstudio/renv#2007 we can just vbump `renv` and
use CRAN version instead of GitHub version.

Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com>
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