rstudio / renv

renv: Project environments for R.
https://rstudio.github.io/renv/
MIT License
1.02k stars 154 forks source link

Capture package repository url and name #1175

Closed kieranjmartin closed 11 months ago

kieranjmartin commented 1 year ago

I'm trying to understand an interaction that seems to happen between rspm and renv. This is for renv version 0.16.0

Apologies that I can't quite make a reprex here as this relies on using an rspm instance.

Lets say I have options(repos =c("rspm/one", "rspm/two")) and install most of my packages.

In my renv.lock file I will have those two repositories listed, and for each package it will say that the source is RSPM.

Now lets say I want to install a package from "rspm/three", but I don't want to add it to my repos options; I just want to install this particular package from this source, but in future I expect to install from rspm/one and rspm/two.

My assumption was I could go:

renv::install("<package>", repos = "rspm/three")
renv::snapshot()

But while this works for the install, the resulting lock file does not contain "rspm/three", either in the list of repositories or for the individual package entry. This means that if this package only exists on "rspm/three" the install will fail for other users.

How do I ensure that this works? I could manually edit the lock file to include the repository, but I'd prefer a programattic flow for this kind of action.

kieranjmartin commented 1 year ago

As a note, I have managed to solve this by installing from the tar gz file at the url. I understand that this is difficult to achieve with the current snapshot strategy, which uses the description file, which does not give enough information for renv to determine what exact rspm url was used. It would be nice if there was some way to hard add this in. I quite like the idea of using source: "rspm url" for that package entry to tell rspm to use something different for that particular package. This is basically similar to how github installs are acheived; renv doesn't add github as a repo, but knows to install from that repo for this particular R package.

kevinushey commented 1 year ago

Maybe it would make sense for renv to record the repository as a source in the package record, if installation is done with a specific repository requested?

That is, if you run:

renv::install("<package>", repos = "rspm/three")

and that requested repository is not set in getOption("repos"), we could take that as a signal that we should record the repository used in the lockfile later during snapshot.

hadley commented 1 year ago

I think install() should record both the repository url and it's name, like this: https://github.com/r-lib/pak/issues/483

Separately we'll also work with the PPM team to add additional fields on their side.

kevinushey commented 11 months ago

This has now been implemented. renv now writes out pak-style remote details for packages installed from CRAN:

> renv::install("colorspace", rebuild = TRUE)
# Downloading packages ------------------------------------
- Downloading colorspace from CRAN ...          OK [2.5 Mb in 0.19s]
Successfully downloaded 1 package in 0.29 seconds.

The following package(s) will be installed:
- colorspace [2.1-0]
These packages will be installed into "~/Library/R/arm64/4.3/library".

Do you want to proceed? [Y/n]: y

# Installing packages -------------------------------------
- Installing colorspace ...                     OK [installed binary and cached in 0.52s]
Successfully installed 1 package in 0.66 seconds.
> packageDescription("colorspace")
Package: colorspace
Version: 2.1-0
Date: 2023-01-23
Title: A Toolbox for Manipulating and Assessing
     Colors and Palettes
Authors@R: c(person(given = "Ross", family =
     "Ihaka", role = "aut", email =
     "ihaka@stat.auckland.ac.nz"), person(given =
     "Paul", family = "Murrell", role = "aut",
     email = "paul@stat.auckland.ac.nz", comment =
     c(ORCID = "0000-0002-3224-8858")),
     person(given = "Kurt", family = "Hornik", role
     = "aut", email = "Kurt.Hornik@R-project.org",
     comment = c(ORCID = "0000-0003-4198-9911")),
     person(given = c("Jason", "C."), family =
     "Fisher", role = "aut", email =
     "jfisher@usgs.gov", comment = c(ORCID =
     "0000-0001-9032-8912")), person(given =
     "Reto", family = "Stauffer", role = "aut",
     email = "Reto.Stauffer@uibk.ac.at", comment =
     c(ORCID = "0000-0002-3798-5507")),
     person(given = c("Claus", "O."), family =
     "Wilke", role = "aut", email =
     "wilke@austin.utexas.edu", comment = c(ORCID =
     "0000-0002-7470-9261")), person(given =
     c("Claire", "D."), family = "McWhite", role =
     "aut", email =
     "claire.mcwhite@utmail.utexas.edu", comment =
     c(ORCID = "0000-0001-7346-3047")),
     person(given = "Achim", family = "Zeileis",
     role = c("aut", "cre"), email =
     "Achim.Zeileis@R-project.org", comment =
     c(ORCID = "0000-0003-0918-3766")))
Description: Carries out mapping between assorted
     color spaces including RGB, HSV, HLS, CIEXYZ,
     CIELUV, HCL (polar CIELUV), CIELAB, and polar
     CIELAB.  Qualitative, sequential, and
     diverging color palettes based on HCL colors
     are provided along with corresponding ggplot2
     color scales.  Color palette choice is aided
     by an interactive app (with either a Tcl/Tk or
     a shiny graphical user interface) and shiny
     apps with an HCL color picker and a color
     vision deficiency emulator. Plotting functions
     for displaying and assessing palettes include
     color swatches, visualizations of the HCL
     space, and trajectories in HCL and/or RGB
     spectrum. Color manipulation functions
     include: desaturation, lightening/darkening,
     mixing, and simulation of color vision
     deficiencies (deutanomaly, protanomaly,
     tritanomaly).  Details can be found on the
     project web page at
     <https://colorspace.R-Forge.R-project.org/>
     and in the accompanying scientific paper:
     Zeileis et al. (2020, Journal of Statistical
     Software, <doi:10.18637/jss.v096.i01>).
Depends: R (>= 3.0.0), methods
Imports: graphics, grDevices, stats
Suggests: datasets, utils, KernSmooth, MASS,
     kernlab, mvtnorm, vcd, tcltk, shiny, shinyjs,
     ggplot2, dplyr, scales, grid, png, jpeg,
     knitr, rmarkdown, RColorBrewer, rcartocolor,
     scico, viridis, wesanderson
VignetteBuilder: knitr
License: BSD_3_clause + file LICENSE
URL: https://colorspace.R-Forge.R-project.org/,
     https://hclwizard.org/
BugReports:
     https://colorspace.R-Forge.R-project.org/contact.html
LazyData: yes
Encoding: UTF-8
RoxygenNote: 7.2.3
NeedsCompilation: yes
Packaged: 2023-01-23 08:50:11 UTC; zeileis
Author: Ross Ihaka [aut], Paul Murrell [aut]
     (<https://orcid.org/0000-0002-3224-8858>),
     Kurt Hornik [aut]
     (<https://orcid.org/0000-0003-4198-9911>),
     Jason C. Fisher [aut]
     (<https://orcid.org/0000-0001-9032-8912>),
     Reto Stauffer [aut]
     (<https://orcid.org/0000-0002-3798-5507>),
     Claus O. Wilke [aut]
     (<https://orcid.org/0000-0002-7470-9261>),
     Claire D. McWhite [aut]
     (<https://orcid.org/0000-0001-7346-3047>),
     Achim Zeileis [aut, cre]
     (<https://orcid.org/0000-0003-0918-3766>)
Maintainer: Achim Zeileis
     <Achim.Zeileis@R-project.org>
Repository: CRAN
Date/Publication: 2023-01-23 11:40:02 UTC
Built: R 4.3.0; aarch64-apple-darwin20; 2023-04-11
     04:31:17 UTC; unix
Archs: colorspace.so.dSYM
RemoteType: standard
RemotePkgRef: colorspace
RemoteRef: colorspace
RemoteRepos: https://cloud.R-project.org
RemoteReposName: CRAN
RemotePkgPlatform: aarch64-apple-darwin20
RemoteSha: 2.1-0

-- File: /Users/kevin/Library/R/arm64/4.3/library/colorspace/Meta/package.rds