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

install_git() fails to install package from AzureDevOps with command status 128 #621

Closed mima25 closed 3 years ago

mima25 commented 3 years ago

We´ve been using remotes v2.3 to install internally developed packages that are stored on AzureDevOps. Unable to use the function since the package upgrade with the following error: remotes::install_git( 'git@ssh.dev.azure.com:v3/dataapi-rclient', git = 'external') 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 ''/usr/bin/git' ls-remote git ssh.dev.azure.com:v3/dataapi-rclient 2>/dev/null' had status 128

session info(): R version 4.1.0 (2021-05-18) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 20.04.2 LTS

Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] remotes_2.4.0

ellisp commented 3 years ago

I have a similar problem with this code (unfortunately not a reproducible example) for installing from a private GitLab repository, which works under 2.3.0 but does not work under 2.4.0:

uid <- getPass::getPass("Enter your GitLab username (not your email address but the actual GitLab name)", noblank = TRUE)

remotes::install_git(
  url = "https://gitlab.com/nous-group/ip/nous.utils",
  credentials = git2r::cred_user_pass(uid, getPass::getPass("GitLab password:")),
  build_opts = c("--no-resave-data", "--no-manual"),
  dependencies = TRUE,
  upgrade = TRUE
)

The error message is

Error: Failed to install 'unknown package' from Git:
  cannot open URL 'https://gitlab.com/nous-group/ip/nous.utils/raw/ebea3e7b9d02447131fedcc65faa303078abaf43/DESCRIPTION'

The user definitely has access to that location (can point their browser there), but installation fails unless we revert to remotes 2.3.0.

joel23888 commented 3 years ago

I had a similar issue and made a simple function to work around this. I am using ssh so I call it by passing an ssh url and git2r::cred_ssh_key() for credentials. It should work for https but untested. It is very basic, so you may need to add further parameters if you need more options when cloning or installing locally:

install_git_alt=function(url, credentials) { 
  x=tempfile()
  git2r::clone(url, local_path=x, credentials=credentials)
  devtools::install_local(x)
}
dakep commented 3 years ago

I have a similar issue for any repository with URLs of the form username@host:repo/ref, and #627 references the same issue. The PR #603 seems to have introduced the issue when trying to parse the URL at https://github.com/r-lib/remotes/blob/a14cf0031da2d083854246914b4974f09656443a/R/install-git.R#L82

I have no idea what this RE is trying to accomplish and hence I will refrain from creating a PR to fix the issue. Maybe the author of the PR @niheaven can take a look at it?

@ellisp: I think your particular issue is actually the same as #625 and is already being taken care of, but not related to how the URL is parsed.