When on an renv enabled project where collaborators or machines may be Linux or macOS, one can generally get binaries to install on Linux or macOS machines, but not both. This is because CRAN hosts macOS binaries, and RSPM hosts Linux binaries, but in renv.lock individual packages are designated by a single repository, even if the package source hash would be identical across repositories. I assume similar issues arise with Windows. I would like there to be a configuration in which the binary version of a package, hosted from either repository, can be preferred for installation on any OS.
In my setup, collaborators may be on Linux or macOS machines, and we use/commit project-level .Rprofile files as well as renv.lock files to keep our environments in sync. The renv-relevant part of the .Rprofile is this:
And so we have renv.lock files that look like this, but the repository source of a package (CRAN/RSPM) generally depends on whether the user who committed the change is on Linux or macOS:
I note I would expect renv.lock to override repository preferences in .Rprofile when running renv::restore(), and the repositories set in .Rprofile() to determine the source of new packages installed into the library. Perhaps packages in renv.lock can have multiple Repository values and there can be an renv.prefer.binary.repository = TRUE option.
In the interim, a workaround would be something like:
if (Sys.info()[["sysname"]] == "Darwin")
options(renv.config.repos.override = <...>)
In other words, you could use the repos override option to change the repositories used during restore / install by renv, in a way that won't be considered on a future snapshot.
When on an
renvenabled project where collaborators or machines may be Linux or macOS, one can generally get binaries to install on Linux or macOS machines, but not both. This is because CRAN hosts macOS binaries, and RSPM hosts Linux binaries, but inrenv.lockindividual packages are designated by a single repository, even if the package source hash would be identical across repositories. I assume similar issues arise with Windows. I would like there to be a configuration in which the binary version of a package, hosted from either repository, can be preferred for installation on any OS.In my setup, collaborators may be on Linux or macOS machines, and we use/commit project-level
.Rprofilefiles as well asrenv.lockfiles to keep our environments in sync. Therenv-relevant part of the.Rprofileis this:And so we have
renv.lockfiles that look like this, but the repository source of a package (CRAN/RSPM) generally depends on whether the user who committed the change is on Linux or macOS:{ "R": { "Version": "4.2.1", "Repositories": [ { "Name": "RSPM", "URL": "https://packagemanager.rstudio.com/all/latest" }, { "Name": "CRAN", "URL": "https://cran.rstudio.com" } ] }, "Packages": { "BH": { "Package": "BH", "Version": "1.78.0-0", "Source": "Repository", "Repository": "CRAN", "Hash": "4e348572ffcaa2fb1e610e7a941f6f3a", "Requirements": [] }, ...I note I would expect
renv.lockto override repository preferences in.Rprofilewhen runningrenv::restore(), and the repositories set in.Rprofile()to determine the source of new packages installed into the library. Perhaps packages inrenv.lockcan have multipleRepositoryvalues and there can be anrenv.prefer.binary.repository = TRUEoption.(Migrating from this post on the RStudio forum: https://community.rstudio.com/t/renv-and-rspm-for-binary-installs-on-shared-linux-mac-project/143054/2 by request of @kevinushey)
The text was updated successfully, but these errors were encountered: