2

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.

laxxy
  • 1,148
  • 8
  • 17

1 Answers1

2

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.)

Kevin Ushey
  • 20,530
  • 5
  • 56
  • 88
  • Thanks! BTW more generally, can `renv` make use of already available & compiled packages in `.libPaths()` to save time re-compiling? I guess the answer is no, probably because there is no guarantee that an installed package doesn't include hardcoded paths somewhere? – laxxy Aug 24 '21 at 11:48
  • BTW, in case someone else is reading this: looks like setting the env. variable this way is necessary at deployment time to activate and install packages into `renv/library`; subsequently the project can be run on the deployment system as normal, with autoloading enabled. – laxxy Aug 24 '21 at 11:51