flathub / com.jetbrains.IntelliJ-IDEA-Ultimate

https://flathub.org/apps/details/com.jetbrains.IntelliJ-IDEA-Ultimate
15 stars 8 forks source link

Scala SDK setup fails with "Error downloading Scala <version>" #13

Open magor opened 5 years ago

magor commented 5 years ago

When trying to setup Scala SDK, if you try to automatically download it via supplied setup form, it fails with eg.

Error downloading Scala 2.12.8
Cannot run program "java" (in directory "/tmp/sbt-project"): error=2, No such file or directory

I'm not sure if it's related to https://github.com/flathub/com.jetbrains.IntelliJ-IDEA-Ultimate/issues/4

I already configured java sdk (installed via flathub extension), seems to be working otherwise.

x80486 commented 5 years ago

Hi @magor, can you explain to me exactly what is it what you are trying to do?

I had the IDE already installed (latest version). I went ahead and installed the Scala plugin, cloned this repository, and trigger a build via the IDE and sbt. Both worked as expected, even though it took ages dumping the project into sbt.

I'm using by default the Scala version that you posted, 2.12.8, and sbt version 1.2.8. It places all the stuff in $HOME/sbt/boot/scala-2.12.8/lib/scala-library.jar. Notice that for that project it will use 2.11.8 because it's configured by default like that in the sbt script.

magor commented 5 years ago

Hi @x80486 , I didn't try anything with sbt directly from cli (in fact, my own project uses gradle).

The problem is, Idea complains there's no Scala SDK in module; see attached screenshot. So I click Setup Scala SDK in yellow bar, Create, Download, OK, then it fails with the error msg (see original comment).

To clarify, same result with my other project, where JDK is properly setup.

screenshot

x80486 commented 5 years ago

I think you would have to give me a sample repository...exactly how you have it right now – but you can delete most of the Scala sources. I'm interested in the setup process only.

If I create a brand new Gradle project (or import one already created) with Scala and IDEA support, I see the step to add the Scala SDK, but that completes successfully.

One thing: I get some errors with OpenJDK 11.x (even if I lower the language level in the IDE config), so I switched to version 8.x and everything is fine.

magor commented 5 years ago

The screenshot is done on spark2.0-examples, which you linked earlier. How is your Scala SDK set up? Did you let IDE download it automatically, as I was trying to, or did you select it manually from directory?

Currently I use OpenJDK8.

x80486 commented 5 years ago

I was able to reproduce this one. My guess is that the Scala plugin is using a hard-coded tmp/ location, the java.io.tmpdir value (from the JVM), or something else I don't know :rofl:

You might want to check what are your defaults for the JVM via java -XshowSettings (within IDEA's Terminal). I will try to use something like this (in the Bash profile) export _JAVA_OPTIONS=-Djava.io.tmpdir=${XDG_CACHE_HOME}/tmp/ to see if it changes anything.

magor commented 5 years ago

This is the output of java -XshowSettings command:

settings.txt

x80486 commented 5 years ago

I tested it...but still no luck. I set the java.io.tmpdir to ${XDG_CACHE_HOME}/tmp/ and it's actually picking the right location (in the error message): Cannot run program "java" (in directory "/var/home/x80486/.var/app/com.jetbrains.IntelliJ-IDEA-Ultimate/cache/tmp/sbt-project"): error=2, No such file or directory.

So I guess the problem is the way this plugin is spawning the java process for that particular flow.

Gradle does the same, and almost everything within IntelliJ IDEA too, but there is no problem. I'll put the JAVA_TOOL_OPTIONS=-Djava.io.tmpdir=${XDG_CACHE_HOME}/tmp/ in the manifest because that sets correctly the tmp location in the JVM. I will also file an issue in the Scala Plugin's YouTrack...and see how that goes.

In the meantime, you can tell sbt to download/pull a Scala SDK and it will successfully download it (to $HOME/.ivy2/ if I remember correctly).

grzegorz700 commented 5 years ago

I had a similar message, I have solved it by 2 actions: 1) Create this folder in temp. (... sbt-project) [Probably not nessesery] 2) Instal Java JRE

After that, this problem disappeared.

hhandoko commented 5 years ago

I can confirm @grzegorz700 's solution. What worked for me was to install Java SDK (I used Azul Zulu 11).