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

libgit2 not recognizing proxy variable #210

Open
cb12991 opened this issue Feb 6, 2024 · 6 comments
Open

libgit2 not recognizing proxy variable #210

cb12991 opened this issue Feb 6, 2024 · 6 comments

Comments

@cb12991
Copy link

cb12991 commented Feb 6, 2024

I cannot connect to GitHub using https protocol. I'm behind a corporate firewall but have curl proxy environment variables set with allow connection via CLI. Any attempt with gert fails unless ssh protocol is used.

gert::git_clone("https://github.com/r-lib/gert")
#> Error in libgit2::git_clone: failed to connect to github.com:

All required credentials seem to be set up correctly (PAT being stored and pulled from OS credential manager on Windows).

gitcreds::gitcreds_get()
#> <gitcreds>
#>   protocol: https
#>   host    : github.com
#>   username: PersonalAccessToken
#>   password: <-- hidden -->

I've tried adding my proxy to git config under both http and https but with no success.

I understand libgit2 is used with gert but it appears that it's the only thing not recognizing the proxy config. Since it isn't packaged though I don't know how to pass the proxy settings to it for it to use. I've tried looking at similar issues online but haven't found a solution.

Created on 2024-02-06 with reprex v2.0.2

@jeroen
Copy link
Member

jeroen commented Feb 8, 2024

I'm not quite sure what the status of the proxy support is in libgit2. Can you review this thread if there are any hints? #122

@cb12991
Copy link
Author

cb12991 commented Feb 12, 2024

I've reviewed that thread many times, but unfortunately haven't found a solution. It looks like I'll just have to avoid using gert and instead run git commands via CLI.

@jeroen
Copy link
Member

jeroen commented Feb 12, 2024

Sorry about that. It is difficult for me to test this because I don't have access to such a proxied windows corp network.

I think there is a setting to pick up the proxy server, but that will still require you to provide crendentials somehow. Does your proxy server itself also require authentication?

@cb12991
Copy link
Author

cb12991 commented Feb 12, 2024

No, it just uses the server address and port number AFAIK. I think Git is using the HTTP_PROXY environment variable somehow; not sure why libgit2 is not.

@LiNk-NY
Copy link

LiNk-NY commented May 14, 2024

@jeroen
I am also running into this. It works when I use git CLI but not with gert::git_clone.
Note that git config --list returns:

http.https://github.com.proxy=http://<IP_ADDRESS>:<PORT>
http.https://github.com.proxysslcainfo=/etc/ssl/certs/local-ca.crt

Does libgit2 use these values?

Note. I am using :

> gert::libgit2_config()
$version
[1] '1.4.2'

@mbannert
Copy link

A few findings, that hopefully help to resolve the libgit2 issue.

  • Based on what http.proxy in https://git-scm.com/docs/git-config says about overriding the http_proxy, I think git does use http_proxy. Also, my corporate environment always worked without an explicit git config declaration, just using a set of http_proxy and HTTP_PROXY variables to make sure both kind of libs (those who insist on uppercase and those which insist on lowercase are happy).

  • it doesn't do any harm to git if a proxy var is configured in your git config.

However, despite https://github.com/libgit2/libgit2/blob/585210ab210800657ca32f843d3dc8e770c2a4d0/src/libgit2/remote.c#L1135
that looks like HTTP_PROXY & co are processed, libgit2 does not seem to respect the PROXY. Is there any way other than falling back to no-gert with system calls? Like passing the proxy var explicitly to gert::git_clone?

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

4 participants