Failed To set Proxy: Wrong parameter libgit2sharp

2019-09-02 21:37发布

I'm having some problems when I try to clone a repository using the library libgit2sharp.

I'm getting this error:

A first chance exception of type 'LibGit2Sharp.LibGit2SharpException' occurred in LibGit2Sharp.dll 
Additional information: Failed to set proxy: Wrong parameter.

I'm trying to clone like this:

var gitServerUri = new Uri(Settings.Default.GitServerUrl);
var cred = Git.Credentials.Get(gitServerUri.Host);

string clonedRepoPath = Repository.Clone(project.GitUrl(),projectLocalPath, new CloneOptions()
        {
            CredentialsProvider = (_url, _user, _cred) => new UsernamePasswordCredentials
            {
                Username = cred.Login,
                Password = cred.Password,
            }
        });

I tried to find in wiki of libgit2sharp where i should put the proxy config, but i didn't found.

I will be grateful if someone can help.

1条回答
地球回转人心会变
2楼-- · 2019-09-02 22:23

Regarding proxy handling, libgit2 and thus LibGit2Sharp behave a lot like the way git itself handles proxy settings.

Those can be defined in the git configuration stores (local, global, system, ...) with the following entry names...

  • remote.<remote_name>.proxy
  • http.proxy

...or set through the environment HTTPS_PROXY or HTTP_PROXY variables.

You can get a better insight about the probing strategy in the actual libgit2 code.

For more detailed information, see the following relevant issues about this topic:

查看更多
登录 后发表回答