Welcome! Please see the About page for a little more info on how this works.

0 votes
in Clojure by

I am trying to use the Cognitect test-runner dependency to run my tests and I am getting a jgit USERAUTH fail when it tries to clone the dependency. I can use other test runners but I really want to know what is going on here. Lots of other people have had this issue, but I haven't found a good explanation of the issue, nor a resolution. Would appreciate both if anyone can help!

I'm using:

Java 8 (tried 11 too)
Mac 10.15.7 (Catalina)

I have a git ssh key without passcode

Can someone explain to me what the issue is? I have an idea that it's to do with jgit/jsch but I don't fully understand what the problem is.

my deps.edn :

  {:paths ["src" "resources"]
        :deps {org.clojure/clojure {:mvn/version "1.10.2"}}
        :aliases
         { :test {:extra-paths ["test"]
            :extra-deps {com.cognitect/test-runner
                               {:git/url "https://github.com/cognitect-labs/test-runner.git"
                                :sha "209b64504cb3bd3b99ecfec7937b358a879f55c1"}}
            :main-opts ["-m" "cognitect.test-runner"]}}

   
 

clj -A:test output:

> Cloning: https://github.com/cognitect-labs/test-runner.git Error

> building classpath. git@github.com:cognitect-labs/test-runner.git:
> USERAUTH fail org.eclipse.jgit.api.errors.TransportException:
> git@github.com:cognitect-labs/test-runner.git: USERAUTH fail
>         at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:248)
>         at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:306)
>         at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:200)
>         at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:89)
>         at clojure.tools.gitlibs.impl$call_with_auth.invokeStatic(impl.clj:52)
>         at clojure.tools.gitlibs.impl$call_with_auth.invoke(impl.clj:43)
>         at clojure.tools.gitlibs.impl$git_clone_bare.invokeStatic(impl.clj:73)
>         at clojure.tools.gitlibs.impl$git_clone_bare.invoke(impl.clj:70)
>         at clojure.tools.gitlibs.impl$ensure_git_dir.invokeStatic(impl.clj:112)
>         at clojure.tools.gitlibs.impl$ensure_git_dir.invoke(impl.clj:102)
>         at clojure.tools.gitlibs$resolve.invokeStatic(gitlibs.clj:33)
>         at clojure.tools.gitlibs$resolve.invoke(gitlibs.clj:29)
>         at clojure.tools.gitlibs$procure.invokeStatic(gitlibs.clj:47)
>         at clojure.tools.gitlibs$procure.invoke(gitlibs.clj:41)
>         at clojure.tools.deps.alpha.extensions.git$eval1316$fn__1318.invoke(git.clj:42)
>         at clojure.lang.MultiFn.invoke(MultiFn.java:239)
>         at clojure.tools.deps.alpha$expand_deps.invokeStatic(alpha.clj:422)
>         at clojure.tools.deps.alpha$expand_deps.invoke(alpha.clj:390)
>         at clojure.tools.deps.alpha$resolve_deps.invokeStatic(alpha.clj:495)
>         at clojure.tools.deps.alpha$resolve_deps.invoke(alpha.clj:475)
>         at clojure.tools.deps.alpha$calc_basis.invokeStatic(alpha.clj:648)
>         at clojure.tools.deps.alpha$calc_basis.invoke(alpha.clj:622)
>         at clojure.tools.deps.alpha.script.make_classpath2$run_core.invokeStatic(make_classpath2.clj:91)
>         at clojure.tools.deps.alpha.script.make_classpath2$run_core.invoke(make_classpath2.clj:57)
>         at clojure.tools.deps.alpha.script.make_classpath2$run.invokeStatic(make_classpath2.clj:119)
>         at clojure.tools.deps.alpha.script.make_classpath2$run.invoke(make_classpath2.clj:113)
>         at clojure.tools.deps.alpha.script.make_classpath2$_main.invokeStatic(make_classpath2.clj:169)
>         at clojure.tools.deps.alpha.script.make_classpath2$_main.doInvoke(make_classpath2.clj:140)
>         at clojure.lang.RestFn.applyTo(RestFn.java:137)
>         at clojure.lang.Var.applyTo(Var.java:705)
>         at clojure.core$apply.invokeStatic(core.clj:667)
>         at clojure.main$main_opt.invokeStatic(main.clj:514)
>         at clojure.main$main_opt.invoke(main.clj:510)
>         at clojure.main$main.invokeStatic(main.clj:664)
>         at clojure.main$main.doInvoke(main.clj:616)
>         at clojure.lang.RestFn.applyTo(RestFn.java:137)
>         at clojure.lang.Var.applyTo(Var.java:705)
>         at clojure.main.main(main.java:40) Caused by: org.eclipse.jgit.errors.TransportException:
> git@github.com:cognitect-labs/test-runner.git: USERAUTH fail
>         at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:172)
>         at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:140)
>         at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:280)
>         at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:170)
>         at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:137)
>         at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:123)
>         at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1269)
>         at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:237)
>         ... 37 more Caused by: com.jcraft.jsch.JSchException: USERAUTH fail
>         at com.jcraft.jsch.UserAuthPublicKey.start(UserAuthPublicKey.java:119)
>         at com.jcraft.jsch.Session.connect(Session.java:470)
>         at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:126)

1 Answer

+1 vote
by

The stacktrace indicates the ssh transport is being used, even though the url you specified is https, not ssh. Using the ssh transport with jgit doesn't work well.

The reason the ssh transport is being used instead of the https transport is likely because you have a configuration setup in ~/.gitconfig telling git to use ssh instead of https for github repos (this is a common thing people have for some reason). It will be a config file line that says something like "insteadOf".

It sounds like the git transport for tools.deps is being reworked and in a future release it will shell out to git instead of using jgit, in which case the ssh transport should be less problematic.

by
Actually the git transport is doing what it's supposed to do here and in its future release shelling out to git it will do exactly the same thing.
by
@hiredman thanks that was indeed the issue.

I had the following in my `~/.gitconfig`:

```
[url "git@github.com:"]
       insteadOf = https://github.com/
```

So when the clojure/clj alias was downloading the test-runner dependency with "https://.." the `instead_of` configuration was swapping it to the ssh path `git@github.com`.

Presumably I will encounter times when I want that mapping though, but I'll be aware of it now.
by
Thanks @alexmiller for replying.  Wouldn't it be good though if `clj` didn't take any notice of what is in ~/.gitconfig for `insteadOf, considering it wants to always use the https and never ssh?
by
clj can use either https or ssh (assuming your config works, which can be tricky right now - better times coming soon for that though). In my opinion, the best thing clj can do is match git behavior so there is one kind of configuration to care about (not git config + another layer of special cases).
by
Thanks Alex, any references as to how to configure for ssh since it is tricky?  Can you point me at what some information about the better time to come? :)
...