skip to Main Content

I’m just new to renv and tried to find something similar to Pythons virtualenv. So renv seems to offer what I need. I also tried packrat, but renv can load the library when one is not in that project folder.

  • When starting R in the renv project directory it loads my package versions for rasterVis_0.51.5 correctly.
Project '/gpfs0/home/user/venv/modelling' loaded. [renv 0.15.5]
>.libPaths()
[1] "/gpfs0/home/user/venv/modelling/renv/library/R-4.0/x86_64-pc-linux-gnu"              
[2] "/gpfs0/global/software/easybuild-broadwell/software/R/4.0.4-foss-2020b-2/lib64/R/library"

after loading rasterVis

> sessionInfo()
R version 4.0.4 (2021-02-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /gpfs0/global/software/easybuild-broadwell/software/OpenBLAS/0.3.12-GCC-10.2.0/lib/libopenblas_haswellp-r0.3.12.so

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

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

other attached packages:
[1] rasterVis_0.51.5 lattice_0.20-41 

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.6          codetools_0.2-18    png_0.1-7          
 [4] viridisLite_0.3.0   zoo_1.8-9           grid_4.0.4         
 [7] renv_0.15.5         raster_3.6-14       hexbin_1.28.2      
[10] sp_1.6-0            latticeExtra_0.6-29 RColorBrewer_1.1-3 
[13] tools_4.0.4         jpeg_0.1-8.1        parallel_4.0.4     
[16] compiler_4.0.4      terra_1.7-3        

  • When I’m in a parallel directory, starting R and loading renv manually by
    renv::load('~/venv/modelling/renv') it does not load my renv but my system package versions.
> renv::load('~/venv/modelling/renv')
* Project '~/venv/modelling/renv' loaded. [renv 0.15.5]
> .libPaths()
[1] "/gpfs0/home/user/venv/modelling/renv/renv/library/R-4.0/x86_64-pc-linux-gnu"         
[2] "/gpfs0/global/software/easybuild-broadwell/software/R/4.0.4-foss-2020b-2/lib64/R/library"

after loading rasterVis

> sessionInfo()
R version 4.0.4 (2021-02-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /gpfs0/global/software/easybuild-broadwell/software/OpenBLAS/0.3.12-GCC-10.2.0/lib/libopenblas_haswellp-r0.3.12.so

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

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

other attached packages:
[1] rasterVis_0.50      latticeExtra_0.6-29 lattice_0.20-41    
[4] terra_1.1-4         raster_3.4-5        sp_1.4-5           

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.6         codetools_0.2-18   zoo_1.8-9          png_0.1-7         
 [5] viridisLite_0.3.0  grid_4.0.4         renv_0.15.5        hexbin_1.28.2     
 [9] RColorBrewer_1.1-2 tools_4.0.4        jpeg_0.1-8.1       parallel_4.0.4    
[13] compiler_4.0.4 

Do you know why it loads correctly renv but not my corresponsing library versions?

2

Answers


  1. Chosen as BEST ANSWER

    Thanks, indedeed it was the not correctly written path even though it stated that it loaded renv correctly. Now I can also load renv from a very different directory. Nice

    This solved it

    renv::load('/gpfs0/home/user/venv/modelling')
    

    So apparently renv can not work with the home shortcut ~. But that message

    * Project '~/venv/modelling/renv' loaded. [renv 0.15.5]
    

    is very misleading when it actually is not loaded.


  2. In this call:

    renv::load(‘~/venv/modelling/renv’)

    I believe you want to use this instead:

    renv::load(‘~/venv/modelling’)

    since the path supplied to renv::load() should be the project root, not the renv folder within the project.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search