Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not find or load main class org.eclipse.jgit.pgm.Main #100

Open
joan38 opened this issue Oct 16, 2015 · 5 comments
Open

Could not find or load main class org.eclipse.jgit.pgm.Main #100

joan38 opened this issue Oct 16, 2015 · 5 comments

Comments

@joan38
Copy link

joan38 commented Oct 16, 2015

Hi there,

Here is one I have:

optimus(sbt2)> git status
Error: Could not find or load main class org.eclipse.jgit.pgm.Main
[info]
java.lang.RuntimeException: Nonzero exit code (1) running JGit.
    at scala.sys.package$.error(package.scala:27)
    at scala.Predef$.error(Predef.scala:142)
    at com.typesafe.sbt.git.JGitRunner$.forkJGitMain(JGitRunner.scala:69)
    at com.typesafe.sbt.git.JGitRunner$.apply(JGitRunner.scala:16)
    at com.typesafe.sbt.SbtGit$GitCommand$$anonfun$1.apply(SbtGit.scala:49)
    at com.typesafe.sbt.SbtGit$GitCommand$$anonfun$1.apply(SbtGit.scala:45)
    at com.typesafe.sbt.SbtGit$GitCommand$$anonfun$3.apply(SbtGit.scala:56)
    at com.typesafe.sbt.SbtGit$GitCommand$$anonfun$3.apply(SbtGit.scala:54)
    at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:59)
    at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:59)
    at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:61)
    at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:61)
    at sbt.Command$.process(Command.scala:93)
    at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:98)
    at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:98)
    at sbt.State$$anon$1.process(State.scala:184)
    at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:98)
    at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:98)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
    at sbt.MainLoop$.next(MainLoop.scala:98)
    at sbt.MainLoop$.run(MainLoop.scala:91)
    at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:70)
    at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:65)
    at sbt.Using.apply(Using.scala:24)
    at sbt.MainLoop$.runWithNewLog(MainLoop.scala:65)
    at sbt.MainLoop$.runAndClearLast(MainLoop.scala:48)
    at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:32)
    at sbt.MainLoop$.runLogged(MainLoop.scala:24)
    at sbt.StandardMain$.runManaged(Main.scala:53)
    at sbt.xMain.run(Main.scala:28)
    at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
    at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
    at xsbt.boot.Launch$.run(Launch.scala:109)
    at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
    at xsbt.boot.Launch$.launch(Launch.scala:117)
    at xsbt.boot.Launch$.apply(Launch.scala:18)
    at xsbt.boot.Boot$.runImpl(Boot.scala:41)
    at xsbt.boot.Boot$.main(Boot.scala:17)
    at xsbt.boot.Boot.main(Boot.scala)
[error] Nonzero exit code (1) running JGit.
[error] Use 'last' for the full log.
optimus(sbt2)>

git.sbt at the root of the project that contains:

useJGit

plugins.sbt that contains:

addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.8.5")

build.sbt that contains:

enablePlugins(GitBranchPrompt)

Cheers

@bchazalet
Copy link
Contributor

@joan38 sorry for the late response. I can't reproduce your issue. Could you create a stub project that reproduces the problem and share it with us? Thanks!

@aradke
Copy link

aradke commented Feb 29, 2016

I have the same issue on a windows 7 machine and sbt-0.13.11. I can reproduce the issue with a stub empty project with the only file the project\plugins.sbt which has the line:

addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.8.5")

Then after running sbt and set useJGit and git status, I get the same error:

Error: Could not find or load main class org.eclipse.jgit.pgm.Main
[info]
java.lang.RuntimeException: Nonzero exit code (1) running JGit.
    at scala.sys.package$.error(package.scala:27)
    at scala.Predef$.error(Predef.scala:142)
...

@aradke
Copy link

aradke commented Feb 29, 2016

I have since been able to fix this issue by replacing the following line in JGitRunner.scala

    val cp = cl.getURLs map (_.getFile) mkString ":"

to

     val cp = cl.getURLs map (_.getFile.replaceFirst("^/([A-Z]):","$1:")) mkString sys.props("path.separator")

There were two issues:

  1. Windows paths from Url have some strange leading '/'
  2. Windows path separators use ";" instead of ":"

@dwijnand
Copy link
Member

We should setup AppVeyor, reproduce a failing test case and then make that change.

Anyone interested in sbt-git on Windows, feel free to send a PR.

@kwalcock
Copy link

This code might work better for Windows and maybe everything else as well:

val cp = cl.getURLs map (url => new File(url.getFile).getCanonicalPath) mkString File.pathSeparator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants