r-lib / pak

A fresh approach to package installation
https://pak.r-lib.org
646 stars 57 forks source link

pak doesn't look at installed packages #471

Closed dmurdoch closed 1 year ago

dmurdoch commented 1 year ago

This may be intentional, but I don't see a reason for it.

I have a local package which is not on CRAN. Let's call it mypkg. It is installed in the current R version, and it does depend on xts, but

pak::pkg_deps_explain("mypkg", "xts")

fails with the error

> pak::pkg_deps_explain("mypkg", "xts")
Error: 
! error in pak subprocess
Caused by error: 
! Could not solve package dependencies:
* mypkg: Can't find package called mypkg.
Type .Last.error to see the more details.

Why not use packageDescription("mypkg") to retrieve the dependencies?

gaborcsardi commented 1 year ago

Yes, that's intentional, to get the same results independently of what is in your library.

installed::... should in theory work for this, but it does not, which is a bug, probably.

local::... works, though, kind of accidentally, if you give the path where the package is installed:

❯ pak::pkg_deps_explain("installed::/Users/gaborcsardi/Library/R/arm64/4.2/library/tibble", "rlang")
Error:
! error in pak subprocess
Caused by error:
! Could not solve package dependencies:
...
❯ pak::pkg_deps_explain("local::/Users/gaborcsardi/Library/R/arm64/4.2/library/tibble", "rlang")
tibble -> lifecycle -> rlang
tibble -> pillar -> lifecycle -> rlang
tibble -> pillar -> rlang
tibble -> pillar -> vctrs -> lifecycle -> rlang
tibble -> pillar -> vctrs -> rlang
tibble -> rlang
tibble -> vctrs -> lifecycle -> rlang
tibble -> vctrs -> rlang
dmurdoch commented 1 year ago

Thanks. The justification probably makes sense, but you might want to expand the error message a little bit for newbies like me, e.g. "mypkg: Can't find package called mypkg in the standard repositories. Use local::mypkg for a local directory."