rstudio / renv

renv: Project environments for R.
https://rstudio.github.io/renv/
MIT License
1.02k stars 155 forks source link

renv not finding installed packages? #1931

Closed timvdstap closed 4 months ago

timvdstap commented 4 months ago

Hi all, beginner with renv here. Pardon my ignorance, I was under the impression that calling renv::restore() would install and attach packages captured in the renv.lock file. Am I mistaken in this? For example, when I execute the code, it tells me e.g. 'could not find function "%>%"', even though dplyr is installed and I can see it in my renv.lock file. Do I still need to load the packages, or am I not using renv properly in my workflow?

[2]: C:/Users/Admin/AppData/Local/R/cache/R/renv/sandbox/windows/R-4.4/x86_64-w64-mingw32/88765555

ABI ------------------------------------------------------------------------
- ABI conflict checks are not available on Windows.

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         : chr(0) 
 $ 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 8
 $ defaultPackages                     : chr [1:6] "datasets" "utils" "grDevices" "graphics" ...
 $ download.file.method                : chr "libcurl"
 $ download.file.extra                 : NULL
 $ install.packages.compile.from.source: chr "interactive"
 $ pkgType                             : chr "both"
 $ repos                               : Named chr "https://cloud.r-project.org"
  ..- attr(*, "names")= chr "CRAN"
 $ renv.consent                        : logi TRUE
 $ renv.verbose                        : logi TRUE

Environment Variables ------------------------------------------------------
HOME                        = C:\Users\Admin\Documents
LANG                        = <NA>
MAKE                        = <NA>
R_LIBS                      = <NA>
R_LIBS_SITE                 = C:/PROGRA~1/R/R-44~1.0/site-library
R_LIBS_USER                 = C:/Users/Admin/Desktop/GitHub/testing-renv/renv/library/windows/R-4.4/x86_64-w64-mingw32
RENV_DEFAULT_R_ENVIRON      = <NA>
RENV_DEFAULT_R_ENVIRON_USER = <NA>
RENV_DEFAULT_R_LIBS         = <NA>
RENV_DEFAULT_R_LIBS_SITE    = C:/PROGRA~1/R/R-44~1.0/site-library
RENV_DEFAULT_R_LIBS_USER    = C:\Users\Admin\AppData\Local/R/win-library/4.4
RENV_DEFAULT_R_PROFILE      = <NA>
RENV_DEFAULT_R_PROFILE_USER = <NA>
RENV_PROJECT                = C:/Users/Admin/Desktop/GitHub/testing-renv

PATH -----------------------------------------------------------------------
- C:\Users\Admin\anaconda3\Scripts
- C:\Users\Admin\anaconda3
- \usr\bin
- \usr\bin
- C:\rtools44\x86_64-w64-mingw32.static.posix\bin
- C:\rtools44\usr\bin
- \usr\bin
- \usr\bin
- \usr\bin
- \usr\bin
- C:\Program Files\R\R-4.4.0\bin\x64
- C:\Program Files (x86)\Common Files\Oracle\Java\javapath
- C:\Windows\system32
- C:\Windows
- C:\Windows\System32\Wbem
- C:\Windows\System32\WindowsPowerShell\v1.0\
- C:\Windows\System32\OpenSSH\
- C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common
- C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR
- C:\Program Files (x86)\PuTTY\
- C:\Program Files (x86)\Sea-Bird\SBEDataProcessing-Win32
- C:\Program Files\Docker\Docker\resources\bin
- C:\ProgramData\DockerDesktop\version-bin
- C:\WINDOWS\system32
- C:\WINDOWS
- C:\WINDOWS\System32\Wbem
- C:\WINDOWS\System32\WindowsPowerShell\v1.0\
- C:\WINDOWS\System32\OpenSSH\
- C:\Program Files\Git\cmd
- C:\Program Files\dotnet\
- C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\
- C:\Program Files (x86)\Microsoft SQL Server\150\Tools\Binn\
- C:\Program Files\Microsoft SQL Server\150\Tools\Binn\
- C:\Program Files\Microsoft SQL Server\150\DTS\Binn\
- C:\Program Files (x86)\Microsoft SQL Server\160\DTS\Binn\
- C:\Program Files\Azure Data Studio\bin
- C:\Users\Admin\AppData\Local\Microsoft\WindowsApps
- C:\Users\Admin\AppData\Roaming\TinyTeX\bin\win32
- C:\Users\Admin\AppData\Local\Programs\Microsoft VS Code\bin
- C:\Users\Admin\AppData\Local\gitkraken\bin
- C:\Users\Admin\AppData\Local\Programs\Quarto\bin
- C:\Users\Admin\AppData\Local\Microsoft\WindowsApps
- C:\Program Files\Azure Data Studio\bin
- C:\Program Files\RStudio\resources\app\bin\quarto\bin
- C:\Program Files\RStudio\resources\app\bin\postback

Cache ----------------------------------------------------------------------
There are a total of 278 packages installed in the renv cache.
Cache path: "C:/Users/Admin/AppData/Local/R/cache/R/renv/cache/v5/windows/R-4.4/x86_64-w64-mingw32"

Perhaps my paths are wrong?

[1] "C:/Users/Admin/Desktop/GitHub/testing-renv/renv/library/windows/R-4.4/x86_64-w64-mingw32"     
[2] "C:/Users/Admin/AppData/Local/R/cache/R/renv/sandbox/windows/R-4.4/x86_64-w64-mingw32/88765555"

Thank you in advance!

kevinushey commented 4 months ago

Pardon my ignorance, I was under the impression that calling renv::restore() would install and attach packages captured in the renv.lock file.

It will install those packages, but it won't load or attach them -- you still need to use library(<pkg>) to load the packages you wish to use, as you normally would in a "regular" R session.

timvdstap commented 4 months ago

Ah, thanks @kevinushey - appreciate it!