Test in Eclipse works but sbt throws MissingRequirementError: object scala.runtime in compiler mirror not found

前端 未结 2 1474
长情又很酷
长情又很酷 2021-01-21 11:10

I am messing around with parsing and scala.tools.nsc.interactive.Global in Scala and I ran into a problem while executing tests under sbt. The tests run fine from E

2条回答
  •  说谎
    说谎 (楼主)
    2021-01-21 11:45

    The scala-library.jar was not missing from the sbt's classpath but from the classpath of Global. Had to set it in code.

    After modifying the source to

    val settings = new Settings
    
    val scalaLibraryPath = "/home/csajka/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.10.3.jar"
    settings.bootclasspath.append(scalaLibraryPath)
    settings.classpath.append(scalaLibraryPath)
    
    val reporter = new ConsoleReporter(settings)
    val global = new Global(settings, reporter, "Study compile")
    

    the problem disappeared.

    Thanks for the tip @blueberryfields!

提交回复
热议问题