Pkg.add() through proxy fails on Julia 0.5, Windows

I have been successfully using Julia 0.4 from behind corporate proxy.
Just trying to upgrade to Julia 0.5 but Pkg() commands fail:

julia> Pkg.init()
INFO: Initializing package repository C:\Users\plowman\.julia\v0.5
INFO: Cloning METADATA from https://github.com/JuliaLang/METADATA.jl
ERROR: GitError(Code:ERROR, Class:OS, Failed to set proxy: The parameter is incorrect.
)
 in macro expansion at .\libgit2\error.jl:99 [inlined]
 in clone(::String, ::String, ::Base.LibGit2.CloneOptions) at .\libgit2\repository.jl:191
 in #clone#109(::String, ::Bool, ::Ptr{Void}, ::Nullable{Base.LibGit2.AbstractCredentials}, ::Function, ::String, ::String) at .\libgit2\libgit2.jl:327
 in (::Base.LibGit2.#kw##clone)(::Array{Any,1}, ::Base.LibGit2.#clone, ::String, ::String) at .\<missing>:0
 in (::Base.Pkg.Dir.##4#6{String,String})() at .\pkg\dir.jl:49
 in cd(::Base.Pkg.Dir.##4#6{String,String}, ::String) at .\file.jl:48
 in init(::String, ::String) at .\pkg\dir.jl:47
 in init() at .\pkg\pkg.jl:70

I have searched for similar issues, but I am rather confused about what has changed.
It seems git is no longer used (and Windows Julia 0.5 download no longer contains Git sub-directory).
So I’m guessing the git config is not relevant here:

git config --global url."https://github.com/".insteadOf git://github.com/
git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080

I have tried Pkg.setprotocol!("https"), but it doesn’t seem to work. (Also docs suggest https is the default)

From this issue: https://groups.google.com/d/msg/julia-users/K-7wYCfaGc8/CeOCUiR_AQAJ :

So do i understand correctly that the current win64 build doesn't include git/ssh via proxy? Or is just the setting in (where?) missing? Is there a counterpart to the https-insteadof-git setting available?
I know it's not helpful, but i get (behind a company http/https proxy) the same error with Pkg.init() (which is in comparision to other RC0 issues a showstopper).

Has anyone else experienced same?
Any suggestions?

I experienced the same and didn’t solve it on that machine yet, but this may have the solution:
https://github.com/JuliaLang/julia/issues/18643

Seems you need to either create a .gitconfig in the user home dir ot set lowercase https_proxy and/or http_proxy environment variables. It would be nice if the system proxy settings could be respected in this case.

Thanks for your reply Bart.

Seems you need to either create a .gitconfig in the user home dir ot set lowercase https_proxy and/or http_proxy environment variables. It would be nice if the system proxy settings could be respected in this case.

This is what I had for Julia v0.4. (both .gitconfig and http_proxy, https_proxy environment variables).

After much playing around I finally have something that seems to work for v0.5: delete .gitconfig and remove the environment variables.

Not sure where the proxy information is coming from now, would be nice to know.

Julia 0.5.0 switched to libgit2 instead of a bundled git install. This means, that shell command like

git config --global proxy:port
git config --global proxy:port
git config --global url."https://".insteadof git://

do not work anymore.

I had to use a .gitconfig in the user-directory instead:

[http]
    	proxy = proxy:port
[https]
    	proxy = proxy:port
[url "https://"]
    	insteadof = git://
1 Like

What do you mean by user-directory? The command above should add exactly the same to ~/.gitconfig.

That command did not work from the julia REPL in shell mode, as git is not found:

shell> git
ERROR: could not spawn `git`: no such file or directory (ENOENT)
 in _jl_spawn(::String, ::Array{String,1}, ::Ptr{Void}, ::Base.Process, ::RawFD, ::RawFD, ::RawFD) at .\process.jl:321
 in #414 at .\process.jl:478 [inlined]
 in setup_stdio(::Base.##414#415{Cmd,Ptr{Void},Base.Process}, ::Tuple{RawFD,RawFD,RawFD}) at .\process.jl:466
 in #spawn#413(::Nullable{Base.ProcessChain}, ::Function, ::Cmd, ::Tuple{RawFD,RawFD,RawFD}, ::Bool, ::Bool) at .\process.jl:477
 in run(::Cmd) at .\process.jl:591
 in repl_cmd(::Cmd, ::Base.Terminals.TTYTerminal) at .\client.jl:91

This happens since julia 0.5.0 - the same procedure worked using 0.4.6
I must admit, that i didn’t try to use the normal windows command line.

By user directory i meant C:\Users\USERNAME.

Just clarifying what works for me now:

For v0.4, I have .gitconfig in user directory.

For v0.5, I need to remove .gitconfig (so I don’t know where proxy info is coming from in this case, but having .gitconfig produces error as in previous post)

Strange, on Windows 7 I had to put a manually created .gitconfig in C:\Users\USERNAME and only then it worked. Environment variables seemed to have no effect, but I only tried setting them using ENV in Julia and then it may be too late.

I’m getting the exact same error, also on windows 7. Tried with and without .gitconfig files in ~ (H:/), as well as c:/Users/[user], and c:/opt/julia/. When I use command line, I can git clone just fine (proxy details in config file). But libgit2 isn’t grabbing the proxy info like it should. What to do?

On Windows 7, it seemed to me the .gitconfig worked. Are you sure it’s in the correct user home dir (C:/Users/Username by default) and that it is really .gitconfig and not .gitconfig.txt (like I managed to do on my first attempt)?

I’ve tried a few different places, including c:/Users/user, as well as H:/, which is where the command defaults to when I type cd ~ in command line. H is actually a network drive, setup as default home drive for my user on corporate network. Maybe that is contributing to the problem?

bump…anyone able to replicate / have any further ideas? Would be nice if you could do something like cygwin, eg “Copy Proxy Settings from Internet Explorer”

For me .gitconfig in the home directory works on the win7 machine at work, but it has a local home directory. One possibility I see is that libgit2 doesn’t read a .gitconfig on a network drive, but I found no confirmation about that on the web. I agree that the proper solution for this is to read system proxy settings on systems that support this notion, but I think that would require patching libgit2 and/or any lower-level libraries it uses for http access.

i have determined that libgit2 is looking at the config files in c:/Users/user and in c:/ProgramData/Git; when I make incorrectly formatted edits in text editor, I get a different error with Pkg.init() (failed to parse file…). What then is causing errors with proxy in libgit?

  1. possibly another gitconfig file that is overriding these two? I can’t find one though.
  2. some kind of problem with special characters? I’ve tried encoding th…works fine with git from cmd prompt or powershell, but maybe libgit is different?

My error at Pkg.init() still reads the same:

GitError(Code:ERROR, Class:OS, Failsd to set proxy: the parameter is incorrect.)…

I think libgit2 might not parse user credentials in the proxy setting properly.

Specifying username and password does not work for me on Julia v0.5 (libgit2). It did work on Julia v0.4 (git).

proxy = http://username:password@server:port

results in the following error on Julia v0.5:

ERROR: GitError(Code:ERROR, Class:OS, Failed to set proxy: The parameter is incorrect.)

Omitting the username and password seems to work:

proxy = http://server:port

So this is what I have now in .gitconfig in home directory. It seems to work for both Julia v0.4 and v0.5:

[url "https://github.com/"]
	insteadOf = git://github.com/
[http]
	proxy = http://server:port

Note that [https] does not seem necessary.

I think the libgit2 version included in 0.5 just missed the libgit2 commit adding support for parsing credentials from .gitconfig. So there’s a fairly good chance this will work on master/0.6.

1 Like

A post was merged into an existing topic: Troubleshooting libgit2

Ok, so I wait for the new version. Nevertheless - since this is a discussion group - I’m a little bit disappointed, that something this essential and important causes so much errors (if I follow the google hits). Especially when Julia is installed out of the box without any modification. Since the environment variables HTTP_PROXY, ... works for many years perfectly with PYTHON and R, this should be no problem for Julia! I’m 95% pythonic and with the remaining 5% on R. I wanted to give Julia a chance but now I’m not sure, wether it’s worth or not. It took me hours to search the web an test all suggested solutions - whithout success. Why is it necessary to fiddle with files like .gitconfig when set HTTP_PROXY can do all the work? Why does IJulia not come with the basic installation (this was may initial problem) as Jupyter comes with PYTHON?

At the moment Julia seems to be very young.

Julia is very young :smile: I hope it’s still worth giving it a shot :slight_smile:

Did you try on 0.5.1 and 0.6-alpha, both of which recently got released? My understanding is that some of the work on libgit2 could have fixed some cases of this problem

Using environment variables without .gitconfig should now work with 0.6 https://github.com/JuliaLang/julia/issues/20948#issuecomment-287305414