Building with Ensime deletes all .class files, but

2019-08-07 18:46发布

问题:

I am pretty sure I have setup Emacs, Ensime, SBT, and Scala to work together properly. I am able to edit files and see type errors when I save and have successfully tried using ensime's autorefactoring tools.

The problem is when I try to build my project. Regardless of whether there are any errors are not, pressing C-c C-b b gives me this output:

Latest Compilation Results (q to quit, TAB to jump to next error)
----------------------------------------

0 errors, 0 warnings.

Then I noticed the REPL wasn't loading anything which led me to ask this question, but I found out that if I built my project by calling sbt compile from the command line, I could build my project and using the REPL was fine.

I also saw that after I sucessfully built my project with sbt compile and then tried to work on the project and call "incremental build" (C-c C-b r), I would get:

Asynchronous RPC Aborted: Error occurred in incremental builder. Check the server log.

in the mini-buffer. This is what appeared in the *inferior-ensime-server* buffer:

Handling RPC: (swank:builder-update-files (nil))
Error handling RPC: java.lang.NullPointerException :
scala.reflect.internal.util.BatchSourceFile.hashCode(SourceFile.scala:170)
scala.collection.mutable.FlatHashTable$HashUtils$class.elemHashCode(FlatHashTable.scala:392)
scala.collection.mutable.HashSet.elemHashCode(HashSet.scala:41)
scala.collection.mutable.FlatHashTable$class.containsEntry(FlatHashTable.scala:124)
scala.collection.mutable.HashSet.containsEntry(HashSet.scala:41)
scala.collection.mutable.HashSet.contains(HashSet.scala:58)
scala.collection.GenSetLike$class.apply(GenSetLike.scala:43)
scala.collection.mutable.AbstractSet.apply(Set.scala:45)
scala.collection.SeqLike$$anonfun$distinct$1.apply(SeqLike.scala:490)
scala.collection.immutable.List.foreach(List.scala:309)
scala.collection.SeqLike$class.distinct(SeqLike.scala:489)
scala.collection.AbstractSeq.distinct(Seq.scala:40)
scala.tools.nsc.Global$Run.compileSources(Global.scala:1531)
scala.tools.nsc.Global$Run.compileFiles(Global.scala:1643)
scala.tools.nsc.interactive.RefinedBuildManager.update0$1(RefinedBuildManager.scala:133)
scala.tools.nsc.interactive.RefinedBuildManager.update(RefinedBuildManager.scala:188)
scala.tools.nsc.interactive.RefinedBuildManager.update(RefinedBuildManager.scala:102)
org.ensime.server.IncrementalBuilder$$anonfun$act$1$$anonfun$apply$mcV$sp$1.liftedTree1$1(IncrementalBuilder.scala:124)
org.ensime.server.IncrementalBuilder$$anonfun$act$1$$anonfun$apply$mcV$sp$1.applyOrElse(IncrementalBuilder.scala:93)
scala.runtime.AbstractPartialFunction$mcVL$sp.apply$mcVL$sp(AbstractPartialFunction.scala:33)
scala.runtime.AbstractPartialFunction$mcVL$sp.apply(AbstractPartialFunction.scala:33)
scala.runtime.AbstractPartialFunction$mcVL$sp.apply(AbstractPartialFunction.scala:25)
scala.actors.InternalActor$class.receive(InternalActor.scala:123)
org.ensime.server.IncrementalBuilder.receive(IncrementalBuilder.scala:55)
org.ensime.server.IncrementalBuilder$$anonfun$act$1.apply$mcV$sp(IncrementalBuilder.scala:88)
org.ensime.server.IncrementalBuilder$$anonfun$act$1.apply(IncrementalBuilder.scala:87)
org.ensime.server.IncrementalBuilder$$anonfun$act$1.apply(IncrementalBuilder.scala:87)
scala.actors.Reactor$class.seq(Reactor.scala:285)
org.ensime.server.IncrementalBuilder.seq(IncrementalBuilder.scala:55)
scala.actors.Reactor$$anon$3.andThen(Reactor.scala:263)
scala.actors.Combinators$class.loop(Combinators.scala:28)
org.ensime.server.IncrementalBuilder.loop(IncrementalBuilder.scala:55)
scala.actors.Combinators$$anonfun$loop$1.apply(Combinators.scala:28)
scala.actors.Combinators$$anonfun$loop$1.apply(Combinators.scala:28)
scala.actors.Reactor$$anonfun$seq$1$$anonfun$apply$1.applyOrElse(Reactor.scala:282)
scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:33)
scala.actors.ReactorTask.run(ReactorTask.scala:31)
scala.actors.ReactorTask.compute(ReactorTask.scala:63)
scala.concurrent.forkjoin.RecursiveAction.exec(RecursiveAction.java:160)
scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:262)
scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.pollAndExecAll(ForkJoinPool.java:915)
scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:980)
scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1478)
scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:104)

Writing: (:return (:abort 205 "Error occurred in incremental builder. Check the server log.") 44)

If, I tried to do a full build with C-c C-b b, I would get the original buffer showing no errors or warnings (regardless of if that was the case or not) and see that the original class directory would be deleted.

Why is this happening and how can I get C-c C-b b and C-c C-b r to correctly build the project?

EDIT:

It seems like the class files are being generated inside of the directory where I have ensime installed, which seems quite odd to me...

EDIT 2:

I am getting the following in *Messages* at startup. I don't know if this is relevant:

Eager macro-expansion failure: (error "(ensime-builder-changed-files (ensime-connection)) is not a valid place expression") [3 times]

回答1:

These problems were due to bugs in ensime ; both should be fixed in the current git tree:

https://github.com/ensime/ensime-src.git