Damaged sbt-imported projects (asking for Scala SDK, then not building)

Hi,

I have a problem with sbt-imported projects. Today as I re-opened a project, I first got an error message that no "Scala SDK" was set up. When I clicked that message I was led to a dialog to select such an SDK, but there were no options. I closed and re-opened the project. That same message appeared, but now I could select the sbt-based Scala SDK. But now the build is broken. The run configurations don't work any longer. I simply get a "java.lang.ClassNotFoundException" when I try to run objects in this project. When I press "Make Project" I get compile errors from missing dependencies.

Is there an option to "repair" a broken sbt-project, or is the only possibility to delete the .idea files and re-create the project (which would be bad, because I'd lose all the run configurations)?

__Edit__: The "Project Structure" looks all correct, all the dependencies are there.

Thanks, .h.h.

6 comments
Comment actions Permalink

I think this is a severe problem. I just deleted the .idea files and imported the project anew. It still doesn't build!

Is it possible that the plugin update 1.1.x -> 1.2 -> 1.2.1 broke something in multi-module sbt builds? That would be very unfortunate, as I would have to revert to sbt-idea and third-party sbt plugin.

0
Comment actions Permalink

To reproduce:

    $ git clone https://github.com/Sciss/SoundProcesses.git SP_DEBUG

(last commit as of this writing is b34789f33aa887320324c3299f92c9746dd0d609).

    $ cd SP_DEBUG
    $ sbt compile

This compiles fine. Now open IDEA (I use IntelliJ IDEA 14.0.2 CE with Scala Plug-In 1.2.1). "Import Project..." > Select SP_DEBUG folder > sbt import > auto-import and include sources and docs. Press "Make Project".

I get the following error:

    Error: scalac: error while loading Object, Missing dependency 'object scala in compiler mirror', required by /usr/lib/jvm/java-6-openjdk-amd64/jre/lib/rt.jar(java/lang/Object.class)
    ....
    Warning: scalac: No 'scala-library*.jar' in module dependencies [lucresynth]

?!

0
Comment actions Permalink

After switching to Project SDK: JDK 1.7, make worked again, and then I switched back to JDK 1.6, and make still worked. This is all very mysterious. The same for the original project. Cleared files, import project. Make. Other random "type not found" errors. Change from JDK 1.6 to JDK 1.7. Press Make again. Now it compiles. Now change back to JDK 1.6. Make still works.

Is it possible that the latest Scala Plug-in has some subtle incompatibility with JDK 1.6?

0
Comment actions Permalink

Hi! Thank you for the report.

I've been able to reproduce this problem, but not as you've described it. But first let me tell you a bit about importing SBT projects in IDEA to make it clear in the future.

Importing of SBT project in IDEA is done in two stages: foreground first, resolving only basic structure and dependencies (small dialog window on top of "Import" dialog) and then background stage, resolving sources, docs and everything else (small progress bar in status bar after IDEA main window is opened). Between these two stages project may be in an inconsistent state which may cause different errors in highlighting, resolving and building. I've got your error only while project was being in this inconsistent state, so technically it is not considered to be a bug. However, from your description it is unclear whether you've waited until both stages finished or not. If you are sure that no refreshing/importing/indexing was being run while you were making your project I guess I'll have to ask you for another example project because the one you've mentioned builds fine.

As for changing JDKs, in case of completely imported project it had no impact on compilation, everything was fine.

BTW, I'd like to share a tip about deleting .idea folder and reimporting: If you would like to save some settings, e.g. run configurations or anything else you can delete only .idea/modules, .idea/libraries directories and .idea/sbt.xml file and then reimport project again. We're sorry you have to stick with this workaround, but we haven't found the source of this issue yet.

Hope it will help you!

0
Comment actions Permalink

Thanks for your answer. Unfortunately you seem to not have the problems I have...

I get the same problem with other projects. It seems that when the import was done with an older plugin version (1.1 oder 1.2), they don't open properly with the latest plugin version. I get the yellow warning box "No Scala SDK in module" and when I press "Setup Scala SDK", the "Use library" combo-box is empty.

So I used your hint and only deleted `.idea/modules`, `.idea/libraries` and `.idea/sbt.xml`, then used "Import project" again. This only results in "Error Loading Project" - "Cannot load 4 Modules". So I still have to wipe the whole directory to be able to compile my projects again...

Then when I import that project (`.idea` does not exist at all), I fill out the questions (sbt, JDK, auto-import, ...), I make absolutely sure that no background tasks are running any longer, the whole sbt model has been built, all dependencies have been checked. I press "Make Project", and it just fails with types-not-found. I tried this with multiple projects now. I doesn't matter how long I wait, I can try after minutes to build again, same error.

The only solution right now is to change the JDK from 1.6 to JDK 1.7. So 95% certainly there is bug with the Scala Plug-In and JDK 1.6 support.

Here is the info


$ /usr/lib/jvm/java-1.6.0-openjdk-amd64/bin/java -version
java version "1.6.0_31"
OpenJDK Runtime Environment (IcedTea6 1.13.3) (6b31-1.13.3-1)
OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)


$ java -version
java version "1.7.0_65"
OpenJDK Runtime Environment (IcedTea 2.5.3) (7u71-2.5.3-2)
OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)


I double checked that the SDKs set up in IntelliJ IDEA are complete and correct. (Anyway I never touched them and all was fine before)

I can run `sbt test:compile` on the JDK 1.6 without the slightest problem.

0
Comment actions Permalink

Well, we have no special treatment for JDK 1.6, so maybe we should consider other possibilities. BTW, we've made a couple of fixes for compilation process, but they haven't made their way into release yet. I advise you to try latest EAP or nightly and tell me if this problem still occurs.

0

Please sign in to leave a comment.