Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find out what happened when SBT says "javac returned nonzero exit code"?

Tags:

sbt

I'm trying to move our projects to Java 8. When I run a compile I get this:

[error] (MyProject/compile:compileIncremental) javac returned nonzero exit code

This doesn't happen with Java 7. I suspect it's something to do with us using Lombok.

Is there any way to get the actual output from the javac? I've tried "last" and "lastgrep" but I only see SBT logs.

I'm using SBT 0.13.8

Thanks. Ashley

like image 319
user891603 Avatar asked Jun 30 '15 07:06

user891603


1 Answers

When javaHome setting is set, sbt calls javac by forking the process, and attempts to screen scrape the error message out of the output, which is error-prone. sbt 1.2.0-RC3 improves it a bit, but it's a hack.

One way to avoid that is to make sure javaHome setting is set to None. Around 2015 sbt-extras used to set javaHome quietly from JAVA_HOME environment variable, but I think that's been dropped since 2016 in https://github.com/paulp/sbt-extras/pull/160. Since this question was asked in June 2015, maybe that's what it was hitting at the time. If you're using sbt-extras, please update to the latest.

This might be further supported by Parag's answer/observation:

The error message disappeared on my Mac when I removed the JAVA_HOME variable in .bash_profile and then restarting Terminal.

If you continue to see this issue using sbt 1.x, please report on https://github.com/sbt/zinc/issues/520

like image 121
Eugene Yokota Avatar answered Nov 11 '22 10:11

Eugene Yokota