r-lib / pak

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

support installation from git remotes via git clone #705

Open kevinushey opened 1 month ago

kevinushey commented 1 month ago

For example:

> pak::pkg_install("git::git@github.com:rstudio/gt.git")
Error: 
! error in pak subprocess
Caused by error: 
! Could not solve package dependencies:
* git::git@github.com:rstudio/gt.git: ! pkgdepends resolution error for git::git@github.com:rstudio/gt.git.
Caused by error: 
! Failed to download DESCRIPTION from git repo at <://git@github.com:rstudio/gt.git>.
Caused by error in `(function (e) …`:
! URL rejected: Port number was not a decimal number between 0 and 65535
Type .Last.error to see the more details.

The equivalent remotes invocation works.

> remotes::install_git("git@github.com:rstudio/gt.git")
Downloading git repo git@github.com:rstudio/gt.git
'/usr/bin/git' clone --depth 1 --no-hardlinks git@github.com:rstudio/gt.git /var/folders/9n/3nxsgkrj0rlfx196kzdttpww0000gn/T//RtmpOChrAp/filebbe42139d5f2
Cloning into '/var/folders/9n/3nxsgkrj0rlfx196kzdttpww0000gn/T//RtmpOChrAp/filebbe42139d5f2'...
Running `R CMD build`...
* checking for file ‘/private/var/folders/9n/3nxsgkrj0rlfx196kzdttpww0000gn/T/RtmpOChrAp/filebbe42139d5f2/DESCRIPTION’ ... OK
* preparing ‘gt’:
* checking DESCRIPTION meta-information ... OK
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
Removed empty directory ‘gt/man/figures’
* building ‘gt_0.11.1.9000.tar.gz’
Installing package into ‘/Users/kevin/scratch/renvious123/renv/library/macos/R-4.4/aarch64-apple-darwin20’
(as ‘lib’ is unspecified)
* installing *source* package ‘gt’ ...
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (gt)
gaborcsardi commented 1 month ago

SSH is not supported, only HTTPS:

pak::pkg_install("git::https://github.com/rstudio/gt.git")
kevinushey commented 1 month ago

Is this something that might change in the future, or should I discourage this in renv? I suppose I could also transform such SSH URIs into https URIs, at least for GitHub.

gaborcsardi commented 1 month ago

It is unlikely that it would change any time soon.