Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IDEA Scala: Could not find output directory

Trying to play with scala in IDEA with scala plug-in:

My HelloWorld object:

object HelloWorld {

  def main(args: Array[String]) {
    println("Hello")
  }

}

And sometimes I getting next error when pressing 'Run HelloWorld' from context menu.

    scalac: Error: Could not find an output directory for /Users/username/Work/src/sandbox/src/HelloWorld.scala in List((/Users/username/work/src/sandbox/src,/Users/username/work/src/sandbox/out/production/sandbox))
scala.reflect.internal.FatalError: Could not find an output directory for /Users/username/Work/src/sandbox/src/HelloWorld.scala in List((/Users/username
/work/src/sandbox/src,/Users/username/work/src/sandbox/out/production/sandbox))
at scala.tools.nsc.settings.MutableSettings$OutputDirs.outputDirFor(MutableSettings.scala:303)
at scala.tools.nsc.backend.jvm.BytecodeWriters$class.outputDirectory(BytecodeWriters.scala:26)
at scala.tools.nsc.backend.jvm.BytecodeWriters$class.scala$tools$nsc$backend$jvm$BytecodeWriters$$getFile(BytecodeWriters.scala:37)
at scala.tools.nsc.backend.jvm.BytecodeWriters$ClassBytecodeWriter$class.writeClass(BytecodeWriters.scala:89)
at scala.tools.nsc.backend.jvm.GenASM$AsmPhase$$anon$4.writeClass(GenASM.scala:67)
at scala.tools.nsc.backend.jvm.GenASM$JBuilder.writeIfNotTooBig(GenASM.scala:458)
at scala.tools.nsc.backend.jvm.GenASM$JMirrorBuilder.genMirrorClass(GenASM.scala:2954)
at scala.tools.nsc.backend.jvm.GenASM$AsmPhase.run(GenASM.scala:113)
at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1583)
at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1557)
at scala.tools.nsc.Global$Run.compileSources(Global.scala:1553)
at scala.tools.nsc.Global$Run.compile(Global.scala:1662)
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:26)
at org.jetbrains.jps.incremental.scala.local.LocalServer.compile(LocalServer.scala:25)
at org.jetbrains.jps.incremental.scala.remote.Main$.make(Main.scala:58)
at org.jetbrains.jps.incremental.scala.remote.Main$.nailMain(Main.scala:21)
at org.jetbrains.jps.incremental.scala.remote.Main.nailMain(Main.scala)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
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)

This error very annoying because to fix it I need to restart IDEA, clean/compile my project, add/remove launch configuration few times. Also command line from the error properly can be executed from the terminal manually.

like image 445
zapletnev Avatar asked Apr 04 '14 10:04

zapletnev


1 Answers

Looking at the error comment:

Could not find an output directory for:
/Users/username/Work/src/sandbox/src/HelloWorld.scala

in

  • /Users/username/work/src/sandbox/src
  • /Users/username/work/src/sandbox/out/production/sandbox

Depending on the environment you're running the IntelliJ in the upper/lower case difference matters. Please make sure your user.home property is set correctly.

like image 184
Norbert Radyk Avatar answered Oct 02 '22 19:10

Norbert Radyk