为什么IDEA报告“错误:scalac:在加载Object时出错,在编译器镜像中缺少依赖项'对象scala'”构建scala breeze?

时间:2015-01-27 17:44:46

标签: scala intellij-idea scala-breeze

breeze项目从命令行sbt:

构建得很好
sbt package
...
info] Done packaging.
[info] Packaging /shared/breeze/viz/target/scala-2.11/breeze-viz_2.11-0.11-SNAPSHOT.jar ...
[info] Done packaging.
[success] Total time: 238 s, completed Jan 27, 2015 9:40:03 AM

但是,在IntelliJ IDEA 14中执行Build|Rebuild项目时,会反复出现以下错误:

Error:scalac: error while loading Object, Missing dependency 'object scala in compiler mirror', required by /Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/jre/lib/rt.jar(java/lang/Object.class)

这是完整的堆栈跟踪:

Error:scalac: Error: scala.tools.nsc.typechecker.Namers$Namer.enterExistingSym(Lscala/reflect/internal/Symbols$Symbol;)Lscala/tools/nsc/typechecker/Contexts$Context;
java.lang.NoSuchMethodError: scala.tools.nsc.typechecker.Namers$Namer.enterExistingSym(Lscala/reflect/internal/Symbols$Symbol;)Lscala/tools/nsc/typechecker/Contexts$Context;
    at org.scalamacros.paradise.typechecker.Namers$Namer$class.enterSym(Namers.scala:41)
    at org.scalamacros.paradise.typechecker.Namers$$anon$3.enterSym(Namers.scala:13)
    at org.scalamacros.paradise.typechecker.AnalyzerPlugins$MacroPlugin$.pluginsEnterSym(AnalyzerPlugins.scala:35)
    at scala.tools.nsc.typechecker.AnalyzerPlugins$$anon$13.custom(AnalyzerPlugins.scala:429)
    at scala.tools.nsc.typechecker.AnalyzerPlugins$$anonfun$2.apply(AnalyzerPlugins.scala:371)
    at scala.tools.nsc.typechecker.AnalyzerPlugins$$anonfun$2.apply(AnalyzerPlugins.scala:371)
    at scala.collection.immutable.List.map(List.scala:273)
    at scala.tools.nsc.typechecker.AnalyzerPlugins$class.invoke(AnalyzerPlugins.scala:371)
    at scala.tools.nsc.typechecker.AnalyzerPlugins$class.pluginsEnterSym(AnalyzerPlugins.scala:423)
    at scala.tools.nsc.Global$$anon$1.pluginsEnterSym(Global.scala:463)
    at scala.tools.nsc.typechecker.Namers$Namer.enterSym(Namers.scala:274)
    at scala.tools.nsc.typechecker.Namers$Namer$$anonfun$enterSyms$1.apply(Namers.scala:500)
    at scala.tools.nsc.typechecker.Namers$Namer$$anonfun$enterSyms$1.apply(Namers.scala:499)
    at scala.collection.LinearSeqOptimized$class.foldLeft(LinearSeqOptimized.scala:124)
    at scala.collection.immutable.List.foldLeft(List.scala:84)
    at scala.tools.nsc.typechecker.Namers$Namer.enterSyms(Namers.scala:499)
    at scala.tools.nsc.typechecker.Namers$Namer.templateSig(Namers.scala:925)
    at scala.tools.nsc.typechecker.Namers$Namer.moduleSig(Namers.scala:989)
    at scala.tools.nsc.typechecker.Namers$Namer.getSig$1(Namers.scala:1526)
    at scala.tools.nsc.typechecker.Namers$Namer.typeSig(Namers.scala:1541)
    at scala.tools.nsc.typechecker.Namers$Namer$$anonfun$monoTypeCompleter$1$$anonfun$apply$1.apply$mcV$sp(Namers.scala:781)
    at scala.tools.nsc.typechecker.Namers$Namer$$anonfun$monoTypeCompleter$1$$anonfun$apply$1.apply(Namers.scala:780)
    at scala.tools.nsc.typechecker.Namers$Namer$$anonfun$monoTypeCompleter$1$$anonfun$apply$1.apply(Namers.scala:780)
    at scala.tools.nsc.typechecker.Namers$Namer.scala$tools$nsc$typechecker$Namers$Namer$$logAndValidate(Namers.scala:1568)
    at scala.tools.nsc.typechecker.Namers$Namer$$anonfun$monoTypeCompleter$1.apply(Namers.scala:780)
    at scala.tools.nsc.typechecker.Namers$Namer$$anonfun$monoTypeCompleter$1.apply(Namers.scala:772)
    at scala.tools.nsc.typechecker.Namers$$anon$1.completeImpl(Namers.scala:1684)
    at scala.tools.nsc.typechecker.Namers$LockingTypeCompleter$class.complete(Namers.scala:1692)
    at scala.tools.nsc.typechecker.Namers$$anon$1.complete(Namers.scala:1682)
    at scala.reflect.internal.Symbols$Symbol.info(Symbols.scala:1483)
    at scala.reflect.internal.SymbolTable.openPackageModule(SymbolTable.scala:286)
    at scala.tools.nsc.typechecker.Analyzer$packageObjects$$anon$2$$anon$4.traverse(Analyzer.scala:63)
    at scala.tools.nsc.typechecker.Analyzer$packageObjects$$anon$2$$anon$4.traverse(Analyzer.scala:59)
    at scala.reflect.api.Trees$Traverser$$anonfun$traverseStats$1$$anonfun$apply$1.apply$mcV$sp(Trees.scala:2498)
    at scala.reflect.api.Trees$Traverser.atOwner(Trees.scala:2507)
    at scala.reflect.api.Trees$Traverser.traverseStats(Trees.scala:2497)
    at scala.reflect.internal.Trees$class.itraverse(Trees.scala:1326)
    at scala.reflect.internal.SymbolTable.itraverse(SymbolTable.scala:16)
    at scala.reflect.internal.SymbolTable.itraverse(SymbolTable.scala:16)
    at scala.reflect.api.Trees$Traverser.traverse(Trees.scala:2475)
    at scala.tools.nsc.typechecker.Analyzer$packageObjects$$anon$2$$anon$4.traverse(Analyzer.scala:66)
    at scala.tools.nsc.typechecker.Analyzer$packageObjects$$anon$2$$anon$4.traverse(Analyzer.scala:59)
    at scala.reflect.api.Trees$Traverser$$anonfun$traverseStats$1$$anonfun$apply$1.apply$mcV$sp(Trees.scala:2498)
    at scala.reflect.api.Trees$Traverser.atOwner(Trees.scala:2507)
    at scala.reflect.api.Trees$Traverser.traverseStats(Trees.scala:2497)
    at scala.reflect.internal.Trees$class.itraverse(Trees.scala:1326)
    at scala.reflect.internal.SymbolTable.itraverse(SymbolTable.scala:16)
    at scala.reflect.internal.SymbolTable.itraverse(SymbolTable.scala:16)
    at scala.reflect.api.Trees$Traverser.traverse(Trees.scala:2475)
    at scala.tools.nsc.typechecker.Analyzer$packageObjects$$anon$2$$anon$4.traverse(Analyzer.scala:66)
    at scala.tools.nsc.typechecker.Analyzer$packageObjects$$anon$2$$anon$4.traverse(Analyzer.scala:59)
    at scala.reflect.api.Trees$Traverser.apply(Trees.scala:2513)
    at scala.tools.nsc.typechecker.Analyzer$packageObjects$$anon$2.apply(Analyzer.scala:71)
    at scala.tools.nsc.Global$GlobalPhase$$anonfun$applyPhase$1.apply$mcV$sp(Global.scala:441)
    at scala.tools.nsc.Global$GlobalPhase.withCurrentUnit(Global.scala:432)
    at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:441)
    at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:399)
    at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:399)
    at scala.collection.Iterator$class.foreach(Iterator.scala:750)
    at scala.collection.AbstractIterator.foreach(Iterator.scala:1202)
    at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:399)
    at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1500)
    at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1487)
    at scala.tools.nsc.Global$Run.compileSources(Global.scala:1482)
    at scala.tools.nsc.Global$Run.compile(Global.scala:1580)
    at xsbt.CachedCompiler0.run(CompilerInterface.scala:126)
    at xsbt.CachedCompiler0.run(CompilerInterface.scala:102)
    at xsbt.CompilerInterface.run(CompilerInterface.scala:27)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:102)
    at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:48)
    at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:41)
    at org.jetbrains.jps.incremental.scala.local.IdeaIncrementalCompiler.compile(IdeaIncrementalCompiler.scala:29)
    at org.jetbrains.jps.incremental.scala.local.LocalServer.compile(LocalServer.scala:26)
    at org.jetbrains.jps.incremental.scala.remote.Main$.make(Main.scala:65)
    at org.jetbrains.jps.incremental.scala.remote.Main$.nailMain(Main.scala:23)
    at org.jetbrains.jps.incremental.scala.remote.Main.nailMain(Main.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.martiansoftware.nailgun.NGSession.run(NGSession.java:319)

2 个答案:

答案 0 :(得分:3)

Scala编译器与宏天堂版本之间存在版本不匹配。 Macro-paradise是一个编译器插件,与Scala编译器紧密耦合,因此它是针对完整的Scala版本进行交叉编译的。检查IntelliJ使用的Scala版本,并检查编译的宏天堂Scala版本。

不确定Intellij究竟是如何工作的,但在Eclipse中有一个“Scala安装”配置页面(类似于JDK)。您可以设置与天堂版本匹配的Scala安装。也许IntelliJ有类似的概念。

答案 1 :(得分:0)

enter image description here

就我而言,我切换到 JDK8,现在它构建成功。