Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installing binaries when collaborating across multiple operating systems #1052

Open
noamross opened this issue Jul 26, 2022 · 1 comment
Open

Comments

@noamross
Copy link

@noamross noamross commented Jul 26, 2022

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:

options(
  repos = c(RSPM = "https://packagemanager.rstudio.com/all/latest",
            CRAN = "https://cran.rstudio.com/")
  renv.config.auto.snapshot = TRUE, 
  renv.config.rspm.enabled = TRUE, 
  renv.config.cache.enabled = TRUE
)

source("renv/activate.R")

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:

{
  "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.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.

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

@kevinushey
Copy link
Collaborator

@kevinushey kevinushey commented Jul 27, 2022

Thanks for the bug report!

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants