Deploying projects with renv in offline environment

Viewed 343

What is the correct procedure to deploy packages using renv to an offline machine?

We have an internal CRAN-like repository, which is configured via options(repos = list(cran = "http://our.repo.url")) on both the development machine and the deployment machine. It is specified in renv.lock. The renv package itself is installed on both machines, and both are the same version (1.14).

After deployment, after starting R in the project directory, it hangs for a while, and returns an error:

# Bootstrapping renv 0.14.0--------
Warning: unable to access index for repository https://cloud.r-project.org/src/contrib/:
  cannot open URL 'https://cloud.r-project.org/src/contrib/PACKAGES'
* Downloading renv 0.14.0 ... FAILED

How do I tell renv to either copy itself from the system library, or install from the internal repository?

Copying from the system library would be of course the preferred course of action, to save time compiling.

1 Answers

You might want to file an issue at https://github.com/rstudio/renv/issues since I think renv doesn't currently support loading the renv package from a non-project library path via the autoloader.

That said, you should be able to move forward by disabling the renv auto-loader. Before launching R, you can set the environment variable:

RENV_ACTIVATE_PROJECT = FALSE

Then, when R is started, the renv auto-loader (run via source("renv/activate.R") in the project .Rprofile) will be disabled. You can then later load renv from whichever library path is appropriate, and call renv::load() to manually load a particular project.

(The other alternative to setting that environment variable is simply removing the renv auto-loader from the project .Rprofile.)

Related