Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't SBT 0.7.7 work correctly on my Linux system? (case details inside)

First of all, I'd like to ask to correct my question title if something better comes into your mind.

Let's take a Lift REST web service example from the Simply Lift book by David Pollak here.

If I open a Windows (Windows XP SP3, all the updates, Oracle JDK 7) console inside the directory and run "sbt" (sbt.bat), everything works just fine. But in case I try to do the same (but using "./sbt") in Linux (XUbuntu 11.10, OpenJDK 6, OpenJDK 7, Oracle JDK 7 (tried all of them)), SBT returns (instead of going to SBT console mode) immediately as it has done it's job. This means that may the command be just ./sbt it returns about immediately (after finishing the automatic project maintenance), or be it ./sbt jetty-run - it just starts the web server and shuts it down immediately.

Moreover, a web service I've developed for a project of mine compiles and works ok on Windows, but can't be compiled (using ./sbt compile) on Linux (by the same version of SBT). The error is "source file '/.../src/main/scala/code/lib/FooBar.scala;src/main/scala/bootstrap/liftweb/Boot.scala' could not be found", where "FooBar.scala" is an object where I do all the serves (directly called from Boot.scala).

Any ideas of what can be the reason and how to fix it?

UPDATE: The reason of the first problem (SBT returning to shell instead of offering SBT console) seems to be the file was checked out on Windows and had CR+LF instead of just LF line ending. The solution of source files not being found was in just using clean command to recompile from scratch.

like image 481
Ivan Avatar asked Oct 14 '11 08:10

Ivan


2 Answers

The reason of the first problem (SBT returning to shell instead of offering SBT console) seems to be the file was checked out on Windows and had CR+LF instead of just LF line ending. The solution of source files not being found was in just using clean command to recompile from scratch.

like image 65
Ivan Avatar answered Oct 11 '22 18:10

Ivan


First what happens when you simply type:

java -jar sbt-launch.jar

directly from the command line in the folder where the sbt-launch.jar is placed ?. If the sbt-launch.jar is in the same folder as the sbt script then you can edit the script to look like this:

#!/bin/sh
test -f ~/.sbtconfig && . ~/.sbtconfig
java -Xmx512M ${SBT_OPTS} -jar dirname $0/sbt-launch.jar "$@" 

The dirname $0 construct returns the full path of the sbt script folder without the filename of the script. Using the $SBT_OPTS variable allows you to experiment with the various JVM options, like:

SBT_OPTS="-Xss2M -XX:+CMSClassUnloadingEnabled"

Although I would wait with these options as they are likely not the problem here (however be sure to add CMSClassUnloadingEnable later when SBT is working as it ensures that Scala class definitions generated dynamically when running SBT gets unloaded when they are unused, thus preventing memory errors - see more info here):

Also consider using one of

-Djline.terminal=scala.tools.jline.UnixTerminal

or even

-Djline.terminal=jline.UnsupportedTerminal

in your SBT_OPTS.

Finally what happens if you try a never version of SBT ? (you could try running the SBT 0.11 version of the lift example found here https://github.com/lacy/lift-quickstart).

like image 38
Lars Tackmann Avatar answered Oct 11 '22 17:10

Lars Tackmann