snapcrafters / gradle

A community-maintained package to easily install Gradle on Linux
MIT License
8 stars 14 forks source link

ERROR: JAVA_HOME is set to an invalid directory: /snap/gradle/120/usr/lib/jvm/default-java #17

Closed igfoo closed 3 years ago

igfoo commented 3 years ago

After upgrading to 120 (latest/stable, 7.2), I get

$ gradle                                          

ERROR: JAVA_HOME is set to an invalid directory: /snap/gradle/120/usr/lib/jvm/default-java

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

$ ls /snap/gradle/120/usr/lib/jvm/
java-1.16.0-openjdk-amd64  java-16-openjdk-amd64
$ echo $JAVA_HOME

$ 
dcap0 commented 3 years ago

Having the same issue. Since users can't rename files, the symbolic link for java-1.16.0-openjdk-amd64 should just need a rename to default-java, right?

dcap0 commented 3 years ago

Created Pull Request here

tunix commented 3 years ago

I don't know why they left out a symbolic link to default-java 😞 Maybe we should create it ourselves?

elect86 commented 3 years ago

The snap partition looks like is all read-only, if you want to write anything looks like you have to go through quite some commands :/

tunix commented 3 years ago

The snap partition looks like is all read-only, if you want to write anything looks like you have to go through quite some commands :/

I actually meant to do it inside the PR. JDK for Gradle is bundled into the snap itself and JAVA_HOME points to the bundled JDK. At some point, upstream (or the distro maintainers) broke the symlink we had inside snapcraft.yml which causes this issue. We can either place the symlink back inside the snap or define an absolute path to the JDK directory like @dcap0 did in his PR.

tunix commented 3 years ago

18 should fix this. Please reopen otherwise.

elect86 commented 3 years ago

When will we get the fix downstream?

tunix commented 3 years ago

@elect86 - it was actually present in edge channel but i just moved it into stable channel. please check.

elect86 commented 3 years ago

I have no idea how to force/call an update on snap..

elect86 commented 3 years ago

It looks like it's solved, thanks for fixing it