r-lib / pak

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

Issue with devtools/remotes for RemoteType "git" #653

Open banfai opened 6 days ago

banfai commented 6 days ago

When a package have an item in Remotes section of DESCRIPTION with git::https://..., then it gets installed with RemoteType "git" via pak::local_install_dev_deps(). This causes issues with everything in devtools that depend on remotes (e.g. devtools::build_readme()), because remotes does not recognize git as a valid RemoteType.

The issue is triggered when remotes:::package2remote() is called from devtools via remotes.

I've made two test packages, banfai/remotes.pak.test1 and banfai/remotes.pak.test2 that depends on the former.

Here's the reprex of running pak and devtools from the remotes.pak.test2:

pak::local_install_dev_deps()
#> 
#> → Will install 1 package.
#> → All 2 packages (0 B) are cached.
#> + remotes.pak.test1   0.0.0.9000 [bld][cmp]
#> ℹ No downloads are needed, 1 pkg is cached
#> ✔ Installed remotes.pak.test1 0.0.0.9000 (git::https://github.com/banfai/remotes.pak.test1.git@3cfe256) (125ms)
#> ✔ 1 dep: added 1 [4.5s]
devtools::build_readme()
#> ℹ Installing remotes.pak.test2 in temporary library
#> Error in FUN(X[[i]], ...): can't convert package remotes.pak.test1 with RemoteType 'git' to remote
remotes:::package2remote("remotes.pak.test1")
#> Error in remotes:::package2remote("remotes.pak.test1"): can't convert package remotes.pak.test1 with RemoteType 'git' to remote
utils::packageDescription("remotes.pak.test1")
#> Package: remotes.pak.test1
#> Title: What the Package Does (One Line, Title Case)
#> Version: 0.0.0.9000
#> Authors@R: person("First", "Last", , "first.last@example.com", role =
#>         c("aut", "cre"), comment = c(ORCID = "YOUR-ORCID-ID"))
#> Description: What the package does (one paragraph).
#> License: `use_mit_license()`, `use_gpl3_license()` or friends to pick a
#>         license
#> Encoding: UTF-8
#> Roxygen: list(markdown = TRUE)
#> RoxygenNote: 7.3.1
#> NeedsCompilation: no
#> Packaged: 2024-06-24 14:57:27 UTC; banfaib
#> Author: First Last [aut, cre] (YOUR-ORCID-ID)
#> Maintainer: First Last <first.last@example.com>
#> Built: R 4.4.0; ; 2024-06-24 14:57:27 UTC; windows
#> RemoteType: git
#> RemoteUrl: https://github.com/banfai/remotes.pak.test1.git
#> RemotePkgRef: git::https://github.com/banfai/remotes.pak.test1.git
#> RemoteRef: HEAD
#> RemoteSha: 3cfe256bac615c71382504674821e119a41aae07
#> 
#> -- File: C:/R/R-4.4.0/library/remotes.pak.test1/Meta/package.rds

Created on 2024-06-24 with reprex v2.1.0

I'm not sure if this is a regression of pak, or an issue with remotes, but I didn't want to cross-post it there yet. Please let me know if a remotes issue would be more appropriate.

PS: the test example is a bit contrived, but a realistic usecase of git remote type is e.g. an internal repository on Github Enterprise.