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

renv + pak doesn't work with r-universe repos #2092

Open
Aariq opened this issue Feb 18, 2025 · 3 comments
Open

renv + pak doesn't work with r-universe repos #2092

Aariq opened this issue Feb 18, 2025 · 3 comments

Comments

@Aariq
Copy link

Aariq commented Feb 18, 2025

It seems like maybe the repos argument isn't getting passed to pak correctly or something? renv::restore() seems to fail when the lockfile contains R packages installed from r-universe.

To reproduce:

  1. Create a new RStudio project
  2. install azmetr from r-universe with install.packages("azmetr", repos = c("https://cct-datascience.r-universe.dev", "https://cloud.r-project.org"))
  3. Create an R script with library(azmetr) in it
  4. Run renv::init() + renv::snapshot()
  5. Run options(renv.config.pak.enabled = TRUE)
  6. Run renv::restore()

Resulting error message:

Error:                                                                                       
! error in pak subprocess
Caused by error: 
! Could not solve package dependencies:
* azmetr@0.4.0: Can't find package called [email protected].
* [email protected]: dependency conflict
* [email protected]: dependency conflict
* [email protected]: dependency conflict
* [email protected]: dependency conflict
* [email protected]: dependency conflict
* [email protected]: dependency conflict
* [email protected]: dependency conflict
* [email protected]: dependency conflict
* [email protected]: dependency conflict
* [email protected]: dependency conflict
* [email protected]: dependency conflict
* [email protected]: dependency conflict
* [email protected]: dependency conflict
* [email protected]: dependency conflict
* [email protected]: dependency conflict
* [email protected]: dependency conflict
* [email protected]: dependency conflict
* [email protected]: dependency conflict
* [email protected]: dependency conflict
* [email protected]: dependency conflict
* [email protected]: dependency conflict
* [email protected]: dependency conflict
* [email protected]: dependency conflict
* [email protected]: dependency conflict
Type .Last.error to see the more details.
Traceback (most recent calls last):
6: renv::restore()
5: renv_pak_restore(lockfile = lockfile, packages = packages, exclude = exclude, 
       prompt = prompt, project = project)
4: pak$pkg_install(pkg = remotes, ask = prompt)
3: remote(function(...) get("pkg_install_make_plan", asNamespace("pak"))(...), 
       list(pkg = pkg, lib = lib, upgrade = upgrade, ask = ask, 
           start = start, dependencies = dependencies, loaded = loaded_packages(lib)))
2: err$throw(res$error)
1: base::stop(cond)
sessionInfo()

R version 4.4.1 (2024-06-14)
Platform: x86_64-apple-darwin20
Running under: macOS 15.3.1

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/Phoenix
tzcode source: internal

attached base packages:
[1] stats graphics grDevices datasets utils methods base

loaded via a namespace (and not attached):
[1] compiler_4.4.1 tools_4.4.1 renv_1.1.1 pak_0.8.0

@kevinushey
Copy link
Collaborator

Thanks for the bug report -- unfortunately, pak doesn't support installation of specific packages from specific repositories (at least, in a single call). We could probably collect all of the known repositories and provide those when using pak to install / restore packages, but that feels somewhat brittle.

@Aariq
Copy link
Author

Aariq commented Mar 6, 2025

I see. I guess you'd either have to detect that this was r-universe and do:

pak::pkg_install("azmetr=url::https://cct-datascience.r-universe.dev/src/contrib/azmetr_0.4.0.tar.gz")

perhaps something like this would be a more general solution?

withr::with_options(
  list(repos = c('https://uace-azmet.r-universe.dev', getOption("repos"))),
  pak::pkg_install("azmetr")
)

@kevinushey
Copy link
Collaborator

What if azmetr depends on a package that was installed from another repository as well? Or, what if you had multiple repositories providing the same package, but you needed renv to prefer one of those over the other? That's my main worry.

It's probably not a concern in this case, since there's only a single r-universe package, but I think it could be a problem if you had multiple different r-universe repositories in use, or if there was overlap between the packages provided by the repositories.

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