sbt-git icon indicating copy to clipboard operation
sbt-git copied to clipboard

JGit from sbt shell doesn't work:Could not find or load main class org.eclipse.jgit.pgm.Main

Open apple-corps opened this issue 7 years ago • 4 comments

From the documentation I did these things

addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.9.3") in plugins.sbt enablePlugins(GitBranchPrompt) in build.sbt enablePlugins(GitVersioning) in build.sbt useJGit in git.sbt

Using the git command in the sbt shell

I get git status Error: Could not find or load main class org.eclipse.jgit.pgm.Main [error] Nonzero exit code (1) running JGit.

Looks related to the class loading.

apple-corps avatar Oct 26 '17 22:10 apple-corps

After removing useJGit I still get git status Error: Could not find or load main class org.eclipse.jgit.pgm.Main

Then the functionality seems completely broken.

apple-corps avatar Oct 26 '17 23:10 apple-corps

Possible duplicate of https://github.com/sbt/sbt-git/issues/100, which has a possible fix but is awaiting a test case.

JessePelton avatar Nov 09 '17 13:11 JessePelton

I'm seeing this error in 2019 not just in Windows, but also on Travis running Linux. JGitRunner is apparently not getting the classpath that it needs on line 77. It wouldn't work right for Windows for sure, but Travis should be OK. Perhaps sbt is not arranging the classpath as before. This seems not to work:

    getClass.getClassLoader match {
       case cl: java.net.URLClassLoader =>
         val cp = cl.getURLs map (_.getFile) mkString ":"

kwalcock avatar Oct 10 '19 00:10 kwalcock

I think the problem on Linux is just with a transitive dependency, so see #100 for a correction to the code.

kwalcock avatar Oct 10 '19 06:10 kwalcock