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

Doesn't work with git worktrees

Open fredfp opened this issue 6 years ago • 4 comments

Problem from upstream: https://github.com/sbt/sbt-git/issues/110

see also https://github.com/sbt/sbt/issues/2323

fredfp avatar Mar 07 '18 16:03 fredfp

Thanks for reporting this. I had never heard of Git worktrees so this is all new to me.

What exactly breaks? Does the plugin crash or produce stacktraces? Do you have any suggestions on what should happen in such situations? What kind of information would you like the Git promptlet to show in your prompt?

agemooij avatar Mar 07 '18 17:03 agemooij

I read a few of the bug reports and it seems that we could just depend on command line Git instead of sbt-git.

Is this in any way urgent for you?

agemooij avatar Mar 07 '18 17:03 agemooij

It is not urgent, thank you. I just wanted you to know, sorry I included so little details, here's more.

Using sbt-prompt, and starting sbt from a git worktree, sbt fails to load and crashes with a stacktrace:

[error] org.eclipse.jgit.errors.NoWorkTreeException: Bare Repository has neither a working tree, nor an index [error] at org.eclipse.jgit.lib.Repository.getWorkTree(Repository.java:1379) [error] at org.eclipse.jgit.treewalk.FileTreeIterator.(FileTreeIterator.java:115) [error] at org.eclipse.jgit.treewalk.FileTreeIterator.(FileTreeIterator.java:97) [error] at org.eclipse.jgit.api.StatusCommand.call(StatusCommand.java:139) [error] at com.typesafe.sbt.git.JGit.hasUncommittedChanges(JGit.scala:88) [error] at com.typesafe.sbt.SbtGit$.$anonfun$buildSettings$20(SbtGit.scala:121) [error] at com.typesafe.sbt.SbtGit$.$anonfun$buildSettings$20$adapted(SbtGit.scala:121) [error] at com.typesafe.sbt.git.DefaultReadableGit.withGit(ReadableGit.scala:39) [error] at com.typesafe.sbt.SbtGit$.$anonfun$buildSettings$19(SbtGit.scala:121) [error] at com.typesafe.sbt.SbtGit$.$anonfun$buildSettings$19$adapted(SbtGit.scala:121) [error] at scala.Function1.$anonfun$compose$1(Function1.scala:44) [error] at sbt.internal.util.EvaluateSettings$MixedNode.evaluate0(INode.scala:219) [error] at sbt.internal.util.EvaluateSettings$INode.evaluate(INode.scala:164) [error] at sbt.internal.util.EvaluateSettings.$anonfun$submitEvaluate$1(INode.scala:87) [error] at sbt.internal.util.EvaluateSettings.sbt$internal$util$EvaluateSettings$$run0(INode.scala:98) [error] at sbt.internal.util.EvaluateSettings$$anon$3.run(INode.scala:94) [error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [error] at java.lang.Thread.run(Thread.java:748) [error] org.eclipse.jgit.errors.NoWorkTreeException: Bare Repository has neither a working tree, nor an index [error] Use 'last' for the full log. Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore?

The problem comes from JGit, which is used by sbt-git, which sbt-prompt is using.

Other projects seem to get rid of sbt-git altogether as there seem to be no hope that JGit gets fixed anytime soon (a patch for the problem exists since a few years, but never got merged).

This issue is only about fixing the crash.

fredfp avatar Mar 07 '18 17:03 fredfp

Thanks. It seems the mere presence of sbt-git is causing this since there is no mention of sbt-prompt in the stacktrace. Moving to straight commandline git (and dealing with that not being available) seems like the best way to deal with this.

agemooij avatar Mar 08 '18 08:03 agemooij