SBT terminates silently when failing to download plugin via SSH from remote Git repository


(Neil Hooey) #1

I’m pretty sure I found a bug in SBT where it fails silently when downloading a plugin via SSH from a remote Git repository fails for any reason, one example being that the SSH Agent isn’t set up properly.

Details are here:


(Eugene Yokota) #2

Answered it - https://stackoverflow.com/a/52019360/3827


(Eugene Yokota) #3

Just to make sure that it hasn’t been fixed already, could try with the latest 1.2.1 please?


(Neil Hooey) #4

It has the same behaviour with SBT 1.2.1.

Could you help me with getting SBT to build? I’m following the instructions in the contribution guide, but I’m getting errors:

After running:

for i in sbt io util librarymanagement zinc; do \
  git clone https://github.com/sbt/$i.git && (cd $i; git checkout -b 1.x origin/1.x);
done
cd sbt
./sbt-allsources.sh
# lots of build output

sbt:sbtRoot> compile
# lots of build output

I eventually get this error:

[error] /Users/nhooey/git/github/sbt/util/internal/util-scripted/src/main/java/sbt/internal/scripted/ScriptConfig.java:5:1: cannot access xsbti.Logger
[error]   bad class file: /Users/nhooey/git/github/sbt/util/internal/util-interface/target/util-interface-1.2.0-39070c18e2280bb6532c13709bb12226259c2960.jar(xsbti/Logger.class)
[error]     class file has wrong version 54.0, should be 52.0
[error]     Please remove or make sure it appears in the correct subdirectory of the classpath.
[error] import xsbti.Logger;

(Eugene Yokota) #5

It seems like there’s some confusions around different Java versions in the path? I use jenv http://www.jenv.be/.

Like I wrote on Stackoverflow, I think you can just launch sbt normally and type publishLocal for sbt/sbt only for this change unless you need to change librarymanagement together.


(Neil Hooey) #6

Anyway, the problem with the actual SBT Git cloning code could be found if there was some debug logging in this part of Resolvers.scala.

How can I use the log.debug() function in the context below?

I know I have to at least do import sbt.util.Logger, but I looked through the rest of the code and it’s unclear how to get a log instance variable.

  val git: Resolver = (info: ResolveInfo) => {
    val uri = info.uri.withoutMarkerScheme
    val localCopy = uniqueSubdirectoryFor(uri.copy(scheme = "git"), in = info.staging)
    val from = uri.withoutFragment.toASCIIString

    if (uri.hasFragment) {
      val branch = uri.getFragment
      Some { () =>
        creates(localCopy) {
          run("git", "clone", from, localCopy.getAbsolutePath)
          run(Some(localCopy), "git", "checkout", "-q", branch)
        }
      }
    } else
      Some { () =>
        creates(localCopy) {
          run("git", "clone", "--depth", "1", from, localCopy.getAbsolutePath)
        }
      }
  }

(Eugene Yokota) #7

If the logger isn’t there, then you can’t use sbt’s logger unless you pass that into it.
I’d say use System.err.println("hello") during coding.


(Neil Hooey) #8

I think it’s best to change the code so a log instance is passed all the way through from Load.load() in to Resolver.git, so that when the debug flag is on, SBT will print what it’s actually doing.

I could submit this as a pull request.

What do you think?


(Eugene Yokota) #9

Upon closer inspection, I see in https://github.com/sbt/sbt/blob/v1.2.1/main/src/main/scala/sbt/Resolvers.scala#L82-L101 that git function takes ResolveInfo as a parameter. ResolveInfo has config: LoadBuildConfiguration, and LoadBuildConfiguration has log already.