Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
magor opened this issue Feb 4, 2019 · 9 comments
Open

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

magor opened this issue Feb 4, 2019 · 9 comments
Assignees

Comments

@magor
Copy link

magor commented Feb 4, 2019

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 #4

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

@x80486 x80486 self-assigned this Feb 4, 2019
@x80486
Copy link
Collaborator

x80486 commented Feb 5, 2019

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
Copy link
Author

magor commented Feb 5, 2019

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
Copy link
Collaborator

x80486 commented Feb 6, 2019

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
Copy link
Author

magor commented Feb 6, 2019

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
Copy link
Collaborator

x80486 commented Feb 7, 2019

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 🤣

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
Copy link
Author

magor commented Feb 7, 2019

This is the output of java -XshowSettings command:

settings.txt

@x80486
Copy link
Collaborator

x80486 commented Feb 7, 2019

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
Copy link

grzegorz700 commented Apr 5, 2019

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
Copy link

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

  • I installed my Java SDK via SDKMAN, it seems like this configuration is not supported by IntelliJ.
  • Creating the said temp folder does not work for me, instead IntelliJ tries to create another folder (e.g. /tmp/sbt-project2).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants