harrah/xsbt — Issue #320: calling twitter's util-eval under sbt to compile code dynamically fails, doesn't fail on REPL
Author: ahmetsevki
Created: 2011-12-30 21:41:20+00:00
State: open

I am trying to use twitter eval, running it through sbt commandline.
It works on 64-bit Windows 7 with java version:

java -version
java version "1.7.0_02"
Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
Java HotSpot(TM) 64-Bit Server VM (build 22.0-b10, mixed mode)

But it doesn't work on 32-bit Windows XP

java -version
java version "1.7.0_02"
Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
Java HotSpot(TM) Client VM (build 22.0-b10, mixed mode, sharing)

-----------
It works on the same machine (that it doesn't work using sbt) if I run it through REPL

C:\xxxx\scala\evaltest\src\main\scala>scala -classpath "c:\Documents and Settings\xx\.ivy2\cache\com.twitter\util eval_2.9.1\jars\util-eval_2.9.1-1.12.8.jar"
Welcome to Scala version 2.9.1.final (Java HotSpot(TM) Client VM, Java 1.7.0_02).
Type in expressions to have them evaluated.
Type :help for more information.
scala> val value = (new com.twitter.util.Eval).apply[Int]("1+1")
value: Int = 2
scala>
-----------------
Now, let's run it under sbt (0.11.2)
FILES:
-------
object Main {
def main(args:Array[String])
{
val value = (new com.twitter.util.Eval).apply[Int]("1+1")
println("value is " + value)
}
}

------------------------------
build.sbt

name := "mm"
version := "1.0"
scalaVersion := "2.9.1"
resolvers += "twitter-repo" at "http://maven.twttr.com"
scalacOptions ++= Seq("-deprecation")
libraryDependencies ++= Seq( "com.twitter" % "util-core_2.9.1" % "1.12.8", "com.twitter" % "util-eval_2.9.1" % "1.12.8" )

----------------------------
When I run in sbt It raises the following exception:

[info] Running Main
[error] (run-main) scala.tools.nsc.MissingRequirementError: object scala not found.
scala.tools.nsc.MissingRequirementError: object scala not found.
at scala.tools.nsc.symtab.Definitions$definitions$.getModuleOrClass(Definitions.scala:655)
at scala.tools.nsc.symtab.Definitions$definitions$.getModule(Definitions.scala:605)
at scala.tools.nsc.symtab.Definitions$definitions$.ScalaPackage(Definitions.scala:145)
at scala.tools.nsc.symtab.Definitions$definitions$.ScalaPackageClass(Definitions.scala:146)
at scala.tools.nsc.symtab.Definitions$definitions$.AnyClass(Definitions.scala:176)
at scala.tools.nsc.symtab.Definitions$definitions$.init(Definitions.scala:814)
at scala.tools.nsc.Global$Run.(Global.scala:697)
at com.twitter.util.Eval$StringCompiler.apply(Eval.scala:523)
at com.twitter.util.Eval$StringCompiler$$anonfun$apply$3.apply(Eval.scala:540)
at com.twitter.util.Eval$StringCompiler$$anonfun$apply$3.apply(Eval.scala:539)
at scala.Option.getOrElse(Option.scala:108)
at com.twitter.util.Eval$StringCompiler.apply(Eval.scala:539)
at com.twitter.util.Eval.applyProcessed(Eval.scala:198)
at com.twitter.util.Eval.applyProcessed(Eval.scala:191)
at com.twitter.util.Eval.apply(Eval.scala:137)
at Main$.main(Main.scala:11)
at Main.main(Main.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)
at sun.reflect.NativeMethodAccessorImpl.invoke(UnknownSource)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(UnknownSource)
at java.lang.reflect.Method.invoke(Unknown Source) java.lang.RuntimeException: Nonzero exit code: 1
at scala.sys.package$.error(package.scala:27)
[error] {file:/C:/ahmet/scala/evaltest/}default-74d3a5/compile:run:
Nonzero exit code: 1
[error] Total time: 3 s, completed Dec 29, 2011 1:51:46 PM

------------------------------------------
This is a dumbed down version for reproducing the error. However in my actual program it gives this too:

[error] (run-main) java.lang.Error: typeConstructor inapplicable for
java.lang.Error: typeConstructor inapplicable for
at scala.tools.nsc.symtab.SymbolTable.abort(SymbolTable.scala: 34)
at scala.tools.nsc.symtab.Symbols $Symbol.typeConstructor(Symbols.scala:877)
at scala.tools.nsc.symtab.Definitions$definitions$.scala$tools$nsc$symtab$Definitions$definitions$$booltype(Defnitions.scala:157)
at scala.tools.nsc.symtab.Definitions$definitions$.init(Definitions.scala:814)
at scala.tools.nsc.Global$Run.(Global.scala:697)
at com.twitter.util.Eval$StringCompiler.apply(Eval.scala:523)
at com.twitter.util.Eval$StringCompiler$$anonfun$apply$3.apply(Eval.scala:540)
at com.twitter.util.Eval$StringCompiler$$anonfun$apply$3.apply(Eval.scala:539)
at scala.Option.getOrElse(Option.scala:108)
at com.twitter.util.Eval$StringCompiler.apply(Eval.scala:539)
at com.twitter.util.Eval.applyProcessed(Eval.scala:198)
at com.twitter.util.Eval.applyProcessed(Eval.scala:191)
at com.twitter.util.Eval.apply(Eval.scala:137)
at com.twitter.util.Eval.apply(Eval.scala:171)
at mm.Main$.(Main.scala:18)
at mm.Main$.(Main.scala)
at mm.Main.main(Main.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)
at sun.reflect.NativeMethodAccessorImpl.invoke(UnknownSource)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(UnknownSource)
at java.lang.reflect.Method.invoke(Unknown Source) java.lang.RuntimeException: Nonzero exit code: 1
at scala.sys.package$.error(package.scala:27)