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

Allow installing package dependencies from repositories not named CRAN #1762

Closed
jmcphers opened this issue Nov 16, 2017 · 2 comments
Closed
Labels
Milestone

Comments

@jmcphers
Copy link
Member

Today, we test to see if versions of needed packages are available in either:

  1. a repository named "CRAN", if available, or
  2. the first repository, if repositories are not named.

This logic lives here:

.rs.addFunction("packageCRANVersionAvailable", function(name, version, source) {
# get the specified CRAN repo
repo <- NA
repos <- getOption("repos")
# the repos option is canonically a named character vector, but could also
# be a named list
if (is.character(repos) || is.list(repos)) {
if (is.null(names(repos))) {
# no indication of which repo is which, presume the first entry to be
# CRAN if it's of character type
if (length(repos) > 0 && is.character(repos[[1]]))
repo <- repos[[1]]
} else {
# use repo named CRAN
repo <- as.character(repos["CRAN"])
}
}
# if no default repo and no repo marked CRAN, give up
if (is.na(repo)) {
return(list(version = "", satisfied = FALSE))
}
# get the available packages and extract the version information
type <- ifelse(source, "source", getOption("pkgType"))
pkgs <- available.packages(
contriburl = contrib.url(repo, type = type))
if (!(name %in% row.names(pkgs))) {
return(list(version = "", satisfied = FALSE))
}
pkgVersion <- pkgs[name, "Version"]
return(list(
version = pkgVersion,
satisfied = package_version(pkgVersion) >= package_version(version)))
})

However, we've found in the wild that it's possible that a CRAN-like repository may be named something other than CRAN. This is the motivation this Packrat change, which switches from a whitelist to a blacklist for identifying CRAN-like repos:

rstudio/packrat@4b3e402

We should be more permissive in RStudio, too. The proposal here is to change RStudio such that it looks for needed packages in:

  1. a repository named "CRAN", if available, or
  2. the first repository otherwise, regardless of name.
@jmcphers
Copy link
Member Author

jmcphers commented Dec 1, 2017

Backported to 1.1 in 3c99f02.

@ronblum
Copy link
Contributor

ronblum commented Dec 5, 2017

Verified in RStudio server and desktop v1.1.393.

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

No branches or pull requests

2 participants