r-lib / remotes

Install R packages from GitHub, GitLab, Bitbucket, git, svn repositories, URLs
https://remotes.r-lib.org/
Other
336 stars 153 forks source link

devtools::install_github() success but remotes::install_git() fails #780

Open mabuimo opened 9 months ago

mabuimo commented 9 months ago

I am coming from here. I have observed an extremely annoying issue in corporate environments (Windows 11):

if you are using options(download.file.method = "auto") there is no chance that you will be able to install a package directly from GitHub, For instance, devtools::install_github("hrbrmstr/streamgraph will fail

Downloading GitHub repo hrbrmstr/streamgraph@HEAD
Error in utils::download.file(url, path, method = method, quiet = quiet,  : 
  cannot open URL 'https://api.github.com/repos/hrbrmstr/streamgraph/tarball/HEAD'

If you use remotes::install_git("hrbrmstr/streamgraph") you get

remotes::install_git("hrbrmstr/streamgraph")
Error: Failed to install 'unknown package' from Git:
  Command failed (128)
In addition: Warning message:
In system(full, intern = TRUE, ignore.stderr = quiet) :
  running command '"C:\PROGRA~1\Git\cmd\git.exe" ls-remote hrbrmstr/streamgraph ' had status 128

If now you run options(download.file.method = "wininet")

  1. remotes::install_git() fails
    Error: Failed to install 'unknown package' from Git:
    Command failed (128)
    In addition: Warning message:
    In system(full, intern = TRUE, ignore.stderr = quiet) :
    running command '"C:\PROGRA~1\Git\cmd\git.exe" ls-remote hrbrmstr/streamgraph ' had status 128

    but....

  2. devtools::install_github("hrbrmstr/streamgraph") is successful!!
    
    Downloading GitHub repo hrbrmstr/streamgraph@HEAD
    ── R CMD build ────────────────────────────────────────────────────────────────────────────────────────────────────────────
    ✔  checking for file 'C:\Users\ubs008\AppData\Local\Temp\RtmpCctAnf\remotes700458d053\hrbrmstr-streamgraph-76f7173/DESCRIPTION' (1.3s)
    ─  preparing 'streamgraph': (1s)
    ✔  checking DESCRIPTION meta-information
    ─  checking for LF line-endings in source and make files and shell scripts
    ─  checking for empty or unneeded directories
    ─  building 'streamgraph_0.9.0.tar.gz'
gaborcsardi commented 9 months ago

Yes, I can see that this is annoying, but what can remotes do to improve this? remotes::install_git() uses command line git, so if that doesn't work, I am not sure what we can do.

Btw. you can also try pak::pkg_install("git::https://..."), which might work better, or worse.

mabuimo commented 9 months ago

Hi @gaborcsardi could you elaborate further about what are the core differences between remotes::install_git() and devtools::install_github, please?

gaborcsardi commented 9 months ago

remotes::install_git() uses command line git, or the git2r package. devtools::install_github() and remotes::install_github() (which is the same, effectively) use the GitHub API through HTTP.

conig commented 4 months ago

install_git should take a URL, not a username/repo pair: Try

remotes::install_git("https://github.com/hrbrmstr/streamgraph.git")