8000 Let `install_version()` search for version in multiple repos · Issue #79 · r-lib/remotes · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Let install_version() search for version in multiple repos #79

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 8000 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

Closed
tidy-bot opened this issue Aug 2, 2017 · 8 comments
Closed

Let install_version() search for version in multiple repos #79

tidy-bot opened this issue Aug 2, 2017 · 8 comments
Labels
feature a feature request or enhancement install

Comments

@tidy-bot
Copy link
tidy-bot commented Aug 2, 2017

Issue by kenahoo
Saturday Mar 05, 2016 at 01:12 GMT
Originally opened as r-lib/devtools#1107


TL;DR: I would like to change install_version() so that it will search for the requested version of the package in each of the repositories given, in sequence.

Motivation: my company uses R internally, creating packages for various projects and publishing them to internal CRAN-alike servers for integration by other teams. We have one “cran-stable” for official releases, and one CRAN-alike that updates with new snapshots every time someone pushes to a “develop” branch.

I would like our team to call install_version(pkg, version, repos), which then iterates over each entry of repos until a suitable version is found.

For instance, we might have the following:

repos <- c(Stable="http://myserver/cran-stable",
              Dev="http://myserver/cran-dev",
             CRAN="https://cran.revolutionanalytics.com")
install_version('MyPackage', '0.23', repos)  # Installs from ‘Stable’
install_version('MyPackage', '0.24', repos)  # Installs from ‘Dev’

Right now, it looks like install_version() expects exactly one version of a package to be officially published across all repositories, and it only knows how to look for alternate versions in archive/ directories, under the assumption that the only alternate versions that could exist are previously-published versions.

Also, because packages in the “Dev” server may have versioned dependencies on packages from either repository, the same semantics would need to apply to the dependencies too, so install_version() would call itself recursively to handle them.

I would be happy to work this up as a pull request that keeps the existing semantics of finding packages in archive/ directories too.

@tidy-bot
Copy link
Author
tidy-bot commented Aug 2, 2017

Comment by kenahoo
Saturday Mar 05, 2016 at 01:40 GMT


Looking closer at install_version(), it looks like the version argument is an exact version required, not a minimum version. So my example above would need to be:

repos <- c(Stable="http://myserver/cran-stable",
              Dev="http://myserver/cran-dev",
             CRAN="https://cran.revolutionanalytics.com")
install_version('MyPackage', '>= 0.23', repos)  # Installs from ‘Stable’
install_version('MyPackage', '>= 0.24', repos)  # Installs from ‘Dev’

and the version field would be extended to take a specification like the Depends: and Imports: fields in a DESCRIPTION file (and like those, multiple specs could be provided to be 'and'-ed together).

@tidy-bot tidy-bot added feature a feature request or enhancement install labels Aug 2, 2017
@tidy-bot
Copy link
Author
tidy-bot commented Aug 2, 2017

Comment by jimhester
Monday Mar 07, 2016 at 13:25 GMT


Why can't you use install.packages() directly and adjust the repos option depending on whether you want to install from the stable or development branch? If you want to make this easy to switch just write a simple function to change the repos option.

use_devel <- function(devel = TRUE) {
  repos <- getOption("repos")
  if (isTRUE(devel)) {
    repos["Dev"] <- "http://myserver/cran-dev"
  } else {
    repos <- repos[names(repos) != "Dev"]
  }
  options(repos = repos)
}

@tidy-bot
Copy link
Author
tidy-bot commented Aug 2, 2017

Comment by kenahoo
Monday Mar 07, 2016 at 15:21 GMT


That doesn't work because dev packages can depend on prod packages.

@tidy-bot
Copy link
Author
tidy-bot commented Aug 2, 2017

Comment by jimhester
Monday Mar 07, 2016 at 15:41 GMT


'prod' packages would still be available using install.packages(), just set options(repos = c(Stable = "Stable="http://myserver/cran-stable", CRAN="https://cran.revolutionanalytics.com")) in your personal or site .Rprofile.

@tidy-bot
Copy link
Author
tidy-bot commented Aug 2, 2017

Comment by kenahoo
Monday Mar 07, 2016 at 18:17 GMT


Here's a scenario where that doesn't work:

  Repo-Stable:
    Package A, version 1.2; depends on B (>= 1.0)
    Package B, version 1.4

  Repo-Dev:
    Package A, version 1.3-415; depends on B (>= 1.0)
    Package B, version 1.5-31

If I want to install the 'dev' version of A, then your suggestion would be to call install.packages('A', repos=c(repo.dev, repo.stable)). But that would install B 1.5-31 as a prereq, even though the stable one satisfies the dependency.

In a nutshell, wanting the dev version of a specific package doesn't mean I want the dev version of all the other packages too. If we could make my proposed change to install_version, then the order of repos would indicate the caller's policy (which would usually be "prefer stable packages to dev packages" but might be the other way around; it could also be "prefer our local repo to a remote CRAN repo but fall back if necessary").

Your suggestion of tweaking options('repos') is exactly what we've been doing around here for a long time, but it's gotten extremely fiddly and annoying. It basically makes the developer manually check & satisfy all dependencies up & down the tree, by hand. In contrast, the Java developers in our office just tell Maven which version of which artifact they want, and which repositories can provide it, and Maven just figures everything out, which is what I'm hoping devtools can help with in a similar way.

@tidy-bot
Copy link
Author
tidy-bot commented Aug 2, 2017

Comment by kenahoo
Monday Mar 07, 2016 at 18:37 GMT


Here's my forkbranch where I'm working on this: https://github.com/kenahoo/devtools/commits/install_version-multi

@kenahoo
Copy link
Contributor
kenahoo commented Aug 3, 2017

I ported the above devtools forkbranch to a fork of the new remotes package: https://github.com/kenahoo/remotes/commits/install_version-multi

It's not really ready yet, because it hasn't been adjusted for the fact that install_version first computes the download URL and then installs it - it still does everything in one combined recursive process. I can make that change, but it would be at least a couple of weeks, because I'm going on vacation tomorrow.

@kenahoo
Copy link
Contributor
kenahoo commented Jul 31, 2020

For any observers: this was recently resolved by PR #305, which integrated the requested functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
0