renv installation despite Windows Group Policy

Hi everyone,

I am trying to set up renv on an existing codebase in my organization. We use RStudio both in server Workbench) and desktop form (open source Windows client). My organization restrics what users such as me can execute on their machine using group policies. My understanding is that writing/execution of anything (ex: loading an R library) is prohibited by default, but that several folders are whitelisted. For instance, the folder C:\Program Files\R\R-4.2.0\library\ is whitelisted and the user library is set there as well, therefore enabling editing and using the library.

I successfully managed to set up renv on Workbench, as we don't suffer from the same restrictions, but did not manage to do the same on Windows. When running renv::restore(), I get the following error message:

installing to C:/R_temp/my-project/renv/staging/1/00LOCK-magrittr/00new/magrittr/libs/x64
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for 'magrittr' in inDL(x, as.logical(local), as.logical(now), ...):
 unable to load shared object 'C:/R_temp/my-project/renv/staging/1/00LOCK-magrittr/00new/magrittr/libs/x64/magrittr.dll':
  LoadLibrary failure:  Dieses Programm wurde durch eine Gruppenrichtlinie geblockt. Wenden Sie sich an den Systemadministrator, um weitere Informationen zu erhalten.

Error: loading failed
Execution halted
ERROR: loading failed
* removing 'C:/R_temp/my-project/renv/staging/1/magrittr'
Error: install of package 'magrittr' failed [error code 1]
In addition: There were 15 warnings (use warnings() to see them)

The German error message translates " This program has been blocked by a group policy. Contact the system administrator for more information". My understanding is that renv first installs the package in a temporary folder, then tries to load it and, if successful, moves it to the global cache. Since execution from other location than the local library is prohibited on my machine, the loading fails, making it de facto impossible to install packages with renv in my setting.

To overcome this, I tried to set the following renv options, without success.

options(renv.config.cache.symlinks = TRUE)
options(renv.config.install.transactional = TRUE)
Sys.setenv(RENV_PATHS_CACHE="C:/Program Files/R/R-4.2.0/library/renv_cache")

Many thanks in advance.

I think you want the opposite option here:

options(renv.config.install.transactional = FALSE)

That way, renv won't try to install into the custom staging folder first.

Many thanks for your reply,

Indeed, I missread the documentation, sorry for that. I reran the restoration with options(renv.config.install.transactional = FALSE) (and the two other options). I get the same error, but a slightly different path

installing to C:/R_temp/my-project/renv/library/R-4.2/x86_64-w64-mingw32/00LOCK-magrittr/00new/magrittr/libs/x64
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for 'magrittr' in inDL(x, as.logical(local), as.logical(now), ...):
 unable to load shared object 'C:/R_temp/my-project/renv/library/R-4.2/x86_64-w64-mingw32/00LOCK-magrittr/00new/magrittr/libs/x64/magrittr.dll':
  LoadLibrary failure:  Dieses Programm wurde durch eine Gruppenrichtlinie geblockt. Wenden Sie sich an den Systemadministrator, um weitere Informationen zu erhalten.

Error: loading failed
Execution halted
ERROR: loading failed
* removing 'C:/R_temp/my-project/renv/library/R-4.2/x86_64-w64-mingw32/magrittr'
Error: install of package 'magrittr' failed [error code 1]
In addition: There were 16 warnings (use warnings() to see them)

My understanding is that the installation does not occur in the staging area anymore, but directly in the renv library subfolder, and this despite setting the cache to another location and the use of symlinks. Is it by design? Could it be that some other parameter influences that as well? Or am I missing something here?

FYI, I don't run Sys.setenv() to set the environment variable, but I use the .Renviron file, which works (I tested the value with Sys.getenv()).

Thanks a lot for your time and your help

Right, the sequence is like this:

  1. renv installs the package into the project library,
  2. If enabled, the package is then copied into the cache, and symlinked back into the library.

Is it possible that you still lack the requisite permissions to install / load packages from this folder? If so, you might be able to find a workaround in your environment using the RENV_PATHS_LIBRARY_ROOT environment variable -- see:

for a bit of discussion. In effect, you could set the RENV_PATHS_LIBRARY_ROOT environment variable to a location that you have the requisite read + write permissions.

Thanks a lot for your help @kevinushey! This is indeed what was required.

For future reference, this is what I did. Given that I only have rights to write/execute from the system library (which is also the user library in my case), I created two subfolers within the library folder: one for the renv global cache and one for the project library of my current project. I then set RENV_PATHS_CACHE to the path of the first subfolder and RENV_PATHS_LIBRARY_ROOT to the second. The disadvantage of this approach is that I have to create a project library folder by hand and adapt the value of RENV_PATHS_LIBRARY_ROOT for each project, but it is not a big blocker for now. I guess it would be possible to write a script that programatically creates the folders and adapts the values if necessary.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.