Bug: fork running wrong scala version

21 views
Skip to first unread message

Josh Cough

unread,
Dec 22, 2009, 5:31:54 PM12/22/09
to simple-b...@googlegroups.com
Hi Mark,

Seth and I encountered an error where when we override fork, and do xsbt run, xsbt seems to be running the wrong Scala version. (it could be something else, but obviously similar)

I've attached a very, very simple project with which you can reproduce the error. If you uncomment the fork line in the Project file, you'll get the error. With it commented out, it prints the collect scala version.

Here is all the code:

import sbt._

class ForkFailProject(info: ProjectInfo) extends DefaultProject(info) {
//  override def fork = Some(new ForkScalaRun {})
}

object ForkFail {
  def main(args:Array[String]) {
    println(scala.util.Properties.versionString)
  }
}

#Project properties
#Tue Dec 22 16:14:08 CST 2009
project.organization=Cough
project.name=ForkFail
sbt.version=0.6.8
project.version=1.0
def.scala.version=2.7.7
build.scala.versions=2.8.0.Beta1-RC5
project.initialize=false


And here is the error that I get when fork is uncommented. Unfortunately, it didnt print the scala version, instead had an error:

dhcp-129-105-244-105:tmp jdc974$ xsbt run
[info] Recompiling project definition...
[info]       Source analysis: 1 new/modified, 0 indirectly invalidated, 0 removed.
[info] Building project ForkFail 1.0 against Scala 2.8.0.Beta1-RC5
[info]    using ForkFailProject with sbt 0.6.8 and Scala 2.7.7
[info]
[info] == compile ==
[info]   Source analysis: 0 new/modified, 0 indirectly invalidated, 0 removed.
[info] Compiling main sources...
[info] Nothing to compile.
[info]   Post-analysis: 2 classes.
[info] == compile ==
[info]
[info] == copy-resources ==
[info] == copy-resources ==
[info]
[info] == run ==
[error] java.lang.NoClassDefFoundError: scala/util/PropertiesTrait
[error]     at ForkFail.main(ForkFail.scala)
[error]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[error]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[error]     at java.lang.reflect.Method.invoke(Method.java:597)
[error]     at scala.tools.nsc.ObjectRunner$$anonfun$run$1.apply(ObjectRunner.scala:75)
[error]     at scala.tools.nsc.ObjectRunner$.withContextClassLoader(ObjectRunner.scala:49)
[error]     at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:74)
[error]     at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:154)
[error]     at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
[error] Caused by: java.lang.ClassNotFoundException: scala.util.PropertiesTrait
[error]     at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
[error]     at java.security.AccessController.doPrivileged(Native Method)
[error]     at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
[error]     at java.lang.ClassLoader.loadClass(ClassLoader.java:315)
[error]     at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
[error]     at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:398)
 
ForkFail.tar.gz

Mark Harrah

unread,
Dec 23, 2009, 12:44:13 AM12/23/09
to simple-b...@googlegroups.com
Thanks Josh. You can use:

override def fork =
{
val si = buildScalaInstance
Some(new ForkScalaRun {
override def scalaJars = si.libraryJar :: si.compilerJar :: Nil})
}

until I make ForkScalaRun use the build Scala version by default.

-Mark

Seth Tisue

unread,
Dec 23, 2009, 10:21:48 AM12/23/09
to simple-b...@googlegroups.com
>>>>> "Mark" == Mark Harrah <dmha...@gmail.com> writes:

Mark> Thanks Josh. You can use: override def fork = { val si =
Mark> buildScalaInstance Some(new ForkScalaRun { override def scalaJars
Mark> = si.libraryJar :: si.compilerJar :: Nil}) }
Mark> until I make ForkScalaRun use the build Scala version by default.

works, thanks.

--
Seth Tisue @ Northwestern University | http://tisue.net
lead developer, NetLogo: http://ccl.northwestern.edu/netlogo/

Mark Harrah

unread,
Dec 29, 2009, 10:41:27 PM12/29/09
to simple-b...@googlegroups.com
On Wednesday 23 December 2009, Seth Tisue wrote:
> >>>>> "Mark" == Mark Harrah <dmha...@gmail.com> writes:
>
> Mark> Thanks Josh. You can use: override def fork = { val si =
> Mark> buildScalaInstance Some(new ForkScalaRun { override def scalaJars
> Mark> = si.libraryJar :: si.compilerJar :: Nil}) }
> Mark> until I make ForkScalaRun use the build Scala version by default.
>
> works, thanks.

Ok, I couldn't make the old way do this by default and be compatible, so I at
least tried to make the new way better. There are some new methods called
forkRun that either do the above by default or directly accept a new working
directory or arguments:

override def fork = forkRun
override def fork =
forkRun(new File("different-working-directory"))
override def fork =
forkRun("-Xmx8G" :: Nil)

This is in the just published 0.6.9.

-Mark

Seth Tisue

unread,
Dec 30, 2009, 9:37:42 AM12/30/09
to simple-b...@googlegroups.com
>>>>> "Mark" == Mark Harrah <dmha...@gmail.com> writes:

Mark> Ok, I couldn't make the old way do this by default and be
Mark> compatible, so I at least tried to make the new way better.
Mark> There are some new methods called forkRun that either do the
Mark> above by default or directly accept a new working directory or
Mark> arguments: [...]
Mark> This is in the just published 0.6.9.

Works, thanks!

Reply all
Reply to author
Forward
0 new messages