Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remotes::install_git fails with corporate https server, but command line git and pak::pkg_install work fine #821

Closed
mkoohafkan opened this issue Dec 17, 2024 · 6 comments

Comments

@mkoohafkan
Copy link

mkoohafkan commented Dec 17, 2024

I have a secure (HTTPS) corporate Gitea server with R package repositories. We have our own security certificates, so I have configured git to use schannel for the SSL backend. I am unable to install packages via remotes::install_git():

> remotes::install_git("git::https://my-corporate-server/git/DataMgmt/my.package.git")
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 git::https://my-corporate-server/git/DataMgmt/my.package.git ' had status 128

However, git ls-remote (which is apparently throwing error 128) works fine on the command line:

git ls-remote https://my-corporate-server/git/DataMgmt/my.package.git

76bfc5c209a7e567485e19bf0117fdd920136be3        HEAD
76bfc5c209a7e567485e19bf0117fdd920136be3        refs/heads/master
etc...

and pak::pkg_install() works too:

pak::pkg_install("git::https://my-corporate-server/git/DataMgmt/my.package.git")
Checking for 15 new metadata filesUpdated metadata database: 5.57 MB in 14 files.                    
 Found  10  deps for  1/1  pkgs [⠸] Resolving standard (CRAN/BioC) packagesUpdating metadata databaseUpdating metadata database ... done
 Found  10  deps for  1/1  pkgs [⠦] Resolving standard (CRAN/BioC) packagesWill update 1 package.Will download 1 package with unknown size.
+ my.package 0.10-10.10-1 [bld][cmp][dl]
? Do you want to continue (Y/n) yGetting 1 pkg with unknown sizeGot my.package 0.10-1 (source) (0 B)
✔ Downloaded 1 package (0 B) in 343ms
Installing...Packaging my.package 0.10-1
Installing...Packaged my.package 0.10-1 (1.7s)
ℹ Building my.package 0.10-1Built my.package 0.10-1 (3.8s)
✔ Installed my.package 0.10-1 (git::https://my-corporate-server/git/DataMgmt/my.package.git@76bfc5c) (176ms)

Is this a bug? A setting I'm missing?

@gaborcsardi
Copy link
Member

I don't know. You can try to debug this and see the actual output from git.

@mkoohafkan
Copy link
Author

mkoohafkan commented Dec 17, 2024

debugging leads to remotes:::git(), the call is

result <- in_dir(path, system(full, intern = TRUE, ignore.stderr = quiet))
## Warning message:
## In system(full, intern = TRUE, ignore.stderr = quiet) :
##   running command '"C:\PROGRA~1\Git\cmd\git.exe" ls-remote https://my-corporate-server/git/DataMgmt/my.package.git ' had status 128

result
## character(0)
## attr(,"status")
## [1] 128

# taking a closer look at the function call system(full, intern = TRUE, ignore.stderr = quiet)
full
## [1] "\"C:\\PROGRA~1\\Git\\cmd\\git.exe\" ls-remote https://my-corporate-server/git/DataMgmt/my.package.git "

Which works just fine when I paste it into a command prompt.

@mkoohafkan
Copy link
Author

mkoohafkan commented Dec 17, 2024

OK I should have toggled that quiet argument to FALSE. It seems to be related to my corporate certificates:

result <- in_dir(path, system(full, intern = TRUE, ignore.stderr = FALSE)
fatal: unable to access 'https://my-corporate-server/git/DataMgmt/my.package.git/': SSL certificate problem: self-signed certificate in certificate chain
Warning message:
In system(full, intern = TRUE, ignore.stderr = FALSE) :
  running command '"C:\PROGRA~1\Git\cmd\git.exe" ls-remote https://my-corporate-sever/git/DataMgmt/my.package.git ' had status 128

But remotes is using my git install, which has the following setting:

git config --global http.sslBackend
schannel

So why isn't remotes using schannel? is remotes setting its own git config options somewhere?

@gaborcsardi
Copy link
Member

So why isn't remotes using schannel? is remotes setting its own git config options somewhere?

I would think not, but I don't know, sorry. Try calling git ls-remote from system() to see if that fails as well. If yes, then this is not anything that remotes is doing.

@mkoohafkan
Copy link
Author

mkoohafkan commented Dec 17, 2024

ok, so it appears that the system call is not respecting the user .gitconfig file. the system .gitconfig file in the install directory is still set to use openssl.

I can reproduce this by calling

shell.exec("cmd")

from the debug environment of the remotes::git() call, which opens a console window that is not respecting my user .gitconfig file.

pak is somehow able to call git in a way that captures the user configuration, or otherwise set git to use schannel.

@mkoohafkan
Copy link
Author

This seems to have mysteriously resolved itself, git is now finding the user configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants