git protocol packages

221 views
Skip to first unread message

Blake Johnson

unread,
Mar 28, 2016, 4:01:21 PM3/28/16
to julia-users
Is there a way to still support git protocol (as opposed to https) packages with the new libgit2 based package system? I have a fair number of private packages on a local server, and it sure would be nice to be able to fetch those with SSH key authentication.

Isaiah Norton

unread,
Mar 30, 2016, 9:54:28 AM3/30/16
to julia...@googlegroups.com
I'm not sure if this is supposed to be officially supported yet, but I was able to get ssh:// to work on OS X:

1. `brew install libssh2`
2. from julia root dir: `cd deps && make configure-libgit2 VERBOSE=1`
3. copy the cmake command printed by above, and re-run it manually. For some reason PKG_CONFIG_MODULE didn't detect libgit2 the first time (discovered by trial-and-error, verified by `make distclean-libgit2` and doing the process again).

  it should look something like:

     `cmake {HOME}/git/jl71/deps/srccache/libgit2/ -DCMAKE_INSTALL_PREFIX:PATH={HOME}/git/jl71/usr -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_C_COMPILER="clang" -DCMAKE_C_COMPILER_ARG1="-m64 " -DCMAKE_CXX_COMPILER="clang++" -DCMAKE_CXX_COMPILER_ARG1="-m64 " -DTHREADSAFE=ON -DCMAKE_BUILD_TYPE=Release`


4. in julia root directory: `make clean && make`
5. start ssh-agent. in bash: "$ eval `ssh-agent`"
6. run something that causes ssh-agent to unlock the key, for example regular command line git clone'ing a repository via ssh.

After those steps, the following works:


If I neglect step 6, then the callback ("credentials_cb") gets called indefinitely (noted via print debugging), so it seems that we are missing some step to make ssh-agent unlock the key pair (which happens via system prompt on OS X).

So: it looks like this is almost-supported, but we need to fix build issues and teach the libgit2 wrapper to set up ssh-agent credentials correctly on its own (at least on OS X). Presumably the situation is the same or better on Linux. On Windows, building against libssh2 is explicitly disabled by our Makefile.

Erik Schnetter

unread,
Mar 30, 2016, 3:21:37 PM3/30/16
to julia...@googlegroups.com
I tried installing libssh2 automatically
<https://github.com/eschnett/julia/tree/eschnett/libssh2>, but failed
due to "use of undeclared identifier 'LIBSSH2_KNOWNHOST_KEY_UNKNOWN'".
Apparently, the build process picks up a system include directory that
has another, older libssh2 installed, while detecting where my OpenSSL
library is installed. This looks messy, so I gave up for the time
being. Maybe the solution is to distribute OpenSSL as well. Or to
disable OpenSSL, and use MbedTLS instead (that we also distribute).

If you are using a key chain, then the ssh agent should start
automatically when you log in. This works out of the box for me on OS
X, presumably using the OS X keychain.

Thanks for the pointers.

-erik
--
Erik Schnetter <schn...@gmail.com>
http://www.perimeterinstitute.ca/personal/eschnetter/

Isaiah Norton

unread,
Mar 30, 2016, 3:51:47 PM3/30/16
to julia...@googlegroups.com
The problem is likely that libgit2 detects libssh2 with CMake's PKG_CHECK_MODULE. This uses `pkg-config`, so it finds whatever is already on your system rather than the built-from-source version. There may be some CMake magic to override that behavior, but probably the easiest way around is to pass the required variables to CMake directly when configuring libgit2 from the Julia Makefile. For the variables, see:
If LIBSSH2_FOUND is set before PKG_CHECK_MODULES, then that macro will short-circuit without setting any variables.

Tony Kelman

unread,
Mar 30, 2016, 3:56:51 PM3/30/16
to julia-users
libgit2 can use the osx native tls library on mac, so we shouldn't need openssl there. Not sure why openssh is getting confused. I'm pretty sure there are https keychain helpers out there if it's entering your password for private repos that you're worried about.

Rob J. Goedman

unread,
Mar 31, 2016, 11:17:26 AM3/31/16
to julia...@googlegroups.com
Thanks for the pointers! Having also struggled with private packages on 0.5 for a while now, I tried below steps (a few times). No such luck.

Also, using https: for a private package on 0.5 on my system hangs Pkg.update(). After ^C it states it’s updating TP but that is not the case.

Could that have to do with:
If I neglect step 6, then the callback ("credentials_cb") gets called indefinitely (noted via print debugging), so it seems that we are missing some step to make ssh-agent unlock the key pair (which happens via system prompt on OS X).

Pkg.clone() works.

Regards,
Rob

               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.5.0-dev+3344 (2016-03-31 06:13 UTC)
 _/ |\__'_|_|_|\__'_|  |  master/c7f5926 (fork: 57 commits, 4 days)
|__/                   |  x86_64-apple-darwin15.4.0

julia> Pkg.update()
INFO: Updating METADATA...
INFO: Updating Unitful master...
INFO: Updating CSoM master...
^CWARNING: fetch: InterruptException()
INFO: Updating TP master...
INFO: Updating Benchmarks master...
INFO: Updating NMfE master...
INFO: Updating Jags master...
INFO: Updating ASCIIPlots master...
INFO: Computing changes...
INFO: No packages to install, update or remove

Erik Schnetter

unread,
Mar 31, 2016, 11:40:47 AM3/31/16
to julia...@googlegroups.com
I see the same symptoms.

-erik

Eric Forgy

unread,
Mar 31, 2016, 5:31:13 PM3/31/16
to julia-users
I have the same issue with private repos and SSH on Windows. It was working fine before the switch.

Eric Forgy

unread,
Mar 31, 2016, 5:45:17 PM3/31/16
to julia-users
PS: This also means Travis and Appveyor no longer work for me when the package I'm testing depends on other private repos. I really hope a solution to this problem can be found.

Rob J. Goedman

unread,
Mar 31, 2016, 6:51:26 PM3/31/16
to julia...@googlegroups.com
Just upgraded 0.5 and now it seems to work using https:// !

Not ideal, but way better!
Reply all
Reply to author
Forward
0 new messages