Disable renv global cache during project init


I'm trying to use renv package to init project in Bazel build. I'm using Bazel to prepare a new R environment that will be deployed on other machines and executed from there. When I'm trying to execute this I'm getting the permission error:

Error in file(con, "w") : cannot open the connection
Calls: ... renv_activate_impl -> load -> renv_load_project -> writeLines -> file
In addition: Warning message:
In file(con, "w") :
cannot open file '/Users/gorun/Library/Application Support/renv/projects': Operation not permitted
Traceback (most recent calls last):
6: renv::init(settings = list(use.cache = FALSE))
5: renv_activate_impl(project, version, restart, quiet)
4: load(project, quiet = quiet)
3: renv_load_project(project)
2: writeLines(enc2utf8(projlist), projects, useBytes = TRUE)
1: file(con, "w")
Execution halted

As you can see the command I'm trying to execute is bolded. Instead, I've tried other options:

  • Tried to set the env variable RENV_PATHS_CACHE to /tmp/renv/projects before init project
  • Tried to set the RENV_PATHS_CACHE variable into .Renviron before init project
  • Tried to disable it renv::settings$use.cache(FALSE)

Basically I've tried all ideas mentioned in https://rstudio.github.io/renv/articles/renv.html#cache but no luck.

My question is can I disable the global cache use or can I at least change the default cache directory location before initializing a project?

Thank you.

Note: I have installed R v4.0.2 and renv v0.11.0 on macOs

You might also try setting the RENV_PATHS_ROOT environment variable to a location where you have write access.

@kevinushey Thank you for the reply. Yes, actually I've tried with RENV_PATHS_CACHE but no luck. The variable RENV_PATHS_ROOT helped in this case. Thank you again

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