Issues and questions about renv

Hello, I was giving a test at renv today.
I might be expecting something wrong with the package.
My use case would be the following:

I create my own project, say tracked by git, I install renv, I do renv::init().
I start working I load some packages, I stop working I do renv::snapshot()
I commit and push

Then my colleague clone the git repo I have created.
when he starts R in this repo I would expect

  • renv to be automatically installed*
  • renv::activate() to be called
  • all other packages to be installed*

I added * because I am not sure about something:

  • is the source of each package used stored within the project or even the library itself ? or is it merely information about the packages used that is stored so that the packages can be re-installed (remotely) ?

  • can I ship the compiled packages themselves so people would not have to re-install them ?

Finally I tried it and my coolegue got the following issue:

Failed to find installation of renv -- attempting to bootstrap...

  • Downloading renv 0.8.2-19 ... Error in utils::download.file(url, destfile = destfile, mode = "wb", quiet = TRUE) :

cannot open URL 'https://api.github.com/repos/rstudio/renv/tarball/0.8.2-19'

In addition: Warning message:

In utils::download.file(url, destfile = destfile, mode = "wb", quiet = TRUE) :

cannot open URL 'https://codeload.github.com/rstudio/renv/legacy.tar.gz/0.8.2-19': HTTP status was '404 Not Found'

Warning message:

Failed to find an renv installation: the project will not be loaded.

Use renv::activate() to re-initialize the project.

The article Collaborating with renv describes the workflow that you and your colleague should follow.

In short, your colleague should

  • Install renv
  • Run renv::init() (or renv::restore() )

The information about the packages you use is contained in the renv.lock file. This does not contain the source code or the binary versions of these packages, but merely the information needed to restore these packages.

You can read more about the lock file at https://rstudio.github.io/renv/articles/lockfile.html

Thank you, what renv does is clear now.
The issue remains, why is it

  • failing to install renv for my colleague (same box, same R version)
  • why does it use download.file while in the lock.file renv is supposed to be installed by git (external method)

can you share the lockfile or part of it ?

You should find in it the information about the repos used and where package are from. Those informations will be reuse in your colleague environment to restore the package from the same location. Looking at this file may give you some clues...

Yes, renv will attempt to bootstrap itself when an R session is launched for that project.

This is indeed the case.

In my humble opinion, this would be too heavy-handed. We do not want to automatically install all of the packages recorded within renv.lock without some explicit user gesture. Users can invoke renv::restore() to restore their project library based on what's defined in the lockfile.

Package sources are stored within the lockfile. That is, given the renv.lock lockfile, renv will be able to download and install packages from their declared sources.

You could, but I wouldn't recommend this unless you were sure you and your collaborators were working in identical environments. (This would likely work on Windows, but would likely break on different versions on macOS / Linux)

Sorry, it's likely your colleague attempted to clone and use your project when I had failed to tag the most recent commit of renv on GitHub. It should be fixed now.

1 Like

You're running R in a state where renv itself is not actually installed or available within the project library. For that reason, renv has to fall back to a minimal downloader that knows just enough to be able to download renv either from CRAN (if available), or GitHub otherwise.

1 Like