r-lib / pak

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

Support pkg_install("local::.")? #621

Open kevinushey opened 7 months ago

kevinushey commented 7 months ago

I saw this when trying to install renv locally; not sure if this is something specific to renv or something else:

> pak::pkg_install("local::.")

→ Will update 1 package.
→ Will download 1 package with unknown size.
+ renv 1.0.7.9000 → 1.0.7.9000 👷🏼 ⬇
? Do you want to continue (Y/n) y
ℹ Getting 1 pkg with unknown size
✔ Got renv 1.0.7.9000 (source) (96 B)
✔ Downloaded 1 package (96 B) in 68ms
ℹ Packaging renv 1.0.7.9000
Error:        
! error in pak subprocess
Caused by error in `find_package_root(path)`:
! Could not find R package in `/var/folders/9n/3nxsgkrj0rlfx196kzdttpww0000gn/T//RtmpVlTACb/file2882688a3877/src/contrib/renv_1.0.7.9000.tar.gz-t/testthat/.` or its parent directories.
Type .Last.error to see the more details.
> packageVersion("pak")
[1] '0.7.2'
kevinushey commented 7 months ago

It's probably something specific to renv, since installing rlang seems to work:

> pak::pkg_install("local::rlang")
✔ Loading metadata database ... done

→ Will update 1 package.
→ The package (0 B) is cached.
+ rlang 1.1.3 → 1.1.3.9000 👷🏼
? Do you want to continue (Y/n)
ℹ No downloads are needed, 1 pkg is cached
✔ Got rlang 1.1.3.9000 (source) (96 B)
ℹ Packaging rlang 1.1.3.9000
✔ Packaged rlang 1.1.3.9000 (1.6s)
ℹ Building rlang 1.1.3.9000
✔ Built rlang 1.1.3.9000 (5.9s)
✔ Installed rlang 1.1.3.9000 (local) (36ms)
✔ 1 pkg: upd 1, dld 1 (NA B) [12.8s]

However, I note that for local remotes, pak doesn't write RemoteUrl or anything that could be used to recover the original path to the installed package:

kevin@MBP-P2MQ:~/Library/R/arm64/4.3/library
$ cat rlang/DESCRIPTION | grep Remote
RemotePkgRef: local::rlang
RemoteType: local
gaborcsardi commented 7 months ago
❯ pak::pkg_install("local::.")
✔ Loading metadata database ... done

→ Will update 1 package.
→ The package (0 B) is cached.
+ renv 1.0.7.9000 → 1.0.7.9000 👷🏼‍♂️
? Do you want to continue (Y/n)
ℹ No downloads are needed, 1 pkg is cached
✔ Got renv 1.0.7.9000 (source) (96 B)
ℹ Packaging renv 1.0.7.9000
✔ Packaged renv 1.0.7.9000 (820ms)
ℹ Building renv 1.0.7.9000
✔ Built renv 1.0.7.9000 (4.6s)
✔ Installed renv 1.0.7.9000 (local) (33ms)
✔ 1 pkg: upd 1, dld 1 (NA B) [9.4s]
❯ packageVersion("pak")
[1] ‘0.7.2.9000’

So IDK what's going on there.

However, I note that for local remotes, pak doesn't write RemoteUrl or anything that could be used to recover the original path to the installed package:

Yes, that is intentional, as local directories are much less stable than URLs. E.g. I probably don't want to make upgrade decisions based on the state of the local directory.

I guess we could still add it and then ignore it when calculating what to upgrade, and then we could use for other things in the future.