capsule icon indicating copy to clipboard operation
capsule copied to clipboard

Should capsule transform RSPM repo urls

Open MilesMcBain opened this issue 2 years ago • 1 comments

When writing a lockfile, currently {capsule} diverges from {renv} with respect to RSPM repo URLS.

On a system with:

> options('repos')
$repos
                                                           RSPM 
"https://packagemanager.rstudio.com/all/__linux__/focal/latest" 
                                                           CRAN 
                                     "https://cran.rstudio.com"

{capsule} will write:

    "Repositories": [
      {
        "Name": "RSPM",
        "URL": "https://packagemanager.rstudio.com/all/__linux__/focal/latest"
      },
      {
        "Name": "CRAN",
        "URL": "https://cran.rstudio.com"
      }
    ]

while {renv} writes:

    "Repositories": [
      {
        "Name": "RSPM",
        "URL": "https://packagemanager.rstudio.com/all/latest"
      },
      {
        "Name": "CRAN",
        "URL": "https://cran.rstudio.com"
      }
    ]

Here {renv} has transformed the platform specific binary url for RSPM into a general source package url. However when restoring from the lockfile {renv} will attempt to transform the source url into a platform specific binary one.

I am surprised this hasn't caused issues at work with collaborators working on windows and linux with different repository URLs, so it seems like {renv} falls back to the local system's repo urls if it can't use the lockfile ones. Need to confirm this, but if so, I see no reason to mirror this complexity.

MilesMcBain avatar May 08 '22 09:05 MilesMcBain

I can't see a fallback in {renv}.

So I think a better way of handling this is a new option for resolving repos on restore. Renv uses the lockfile repos with the option to override.

I'll use that override to provide a 'merge' option for repo resolution, which is default for capsule.

Mege works like:

  1. Where conflicting entries exist for a major repo (CRAN, bioc, rspm) prefer the user's configured repo.
  2. If a major repo exists in one but not the other, bring it in.
  3. Major repos have a defined order: bioc, rspm, CRAN.
  4. All other unique repos are brought in, with a message for those coming from the lockfile. - where to place these in the order will be tricky. Probably they should come after the majors, unless the user has explicitly confuguired them otherwise.

MilesMcBain avatar May 08 '22 11:05 MilesMcBain