Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 827822 - dev-util/idea-community fails to locate openjdk:11
Summary: dev-util/idea-community fails to locate openjdk:11
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal minor (vote)
Assignee: Mike Pagano
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-11-29 05:13 UTC by Alex
Modified: 2022-06-05 18:43 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Reqired fix (fix-launch-script-variable-name.patch,533 bytes, patch)
2022-05-11 15:06 UTC, Alex
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex 2021-11-29 05:13:52 UTC
After installing dev-util/idea-community yesterday I found that it can't start, because it tries to launch itself with openjdk:8, which is my default system java-vm.

The code in the launch script that checks for java VM is the following (with my commentary):

if [ -n "$IDEA_JDK" ] && [ -x "$IDEA_JDK/bin/java" ]; then # This fails, IDEA_JDK is not set
  JRE="$IDEA_JDK"
else
  JDK="/opt/openjdk-bin-11" && [[ -d "/opt/openjdk-11" ]] && JDK="/usr/lib64/openjdk-bin-11" # This succeeds, but JDK variable is not used anywhere
fi

BITS=""
if [ -z "$JRE" ] && [ -s "${CONFIG_HOME}/JetBrains/IdeaIC2021.2/idea.jdk" ]; then # This fails, there;'s no file ${CONFIG_HOME}/JetBrains/IdeaIC2021.2/idea.jdk
  USER_JRE=$(cat "${CONFIG_HOME}/JetBrains/IdeaIC2021.2/idea.jdk")
  if [ -x "$USER_JRE/bin/java" ]; then
    JRE="$USER_JRE"
  fi
fi

if [ -z "$JRE" ] && [ "$OS_TYPE" = "Linux" ] && [ "$OS_ARCH" = "x86_64" ] && [ -d "$IDE_HOME/jbr" ]; then # This fails, there's no dir $IDE_HOME/jbr
  JRE="$IDE_HOME/jbr"
fi

# shellcheck disable=SC2153
if [ -z "$JRE" ]; then
  if [ -n "$JDK_HOME" ] && [ -x "$JDK_HOME/bin/java" ]; then # This succeeds, but it's Java 8, not Java 11
    JRE="$JDK_HOME"
  elif [ -n "$JAVA_HOME" ] && [ -x "$JAVA_HOME/bin/java" ]; then
    JRE="$JAVA_HOME"
  fi
fi

if [ -z "$JRE" ]; then
  JAVA_BIN=$(command -v java)
else
  JAVA_BIN="$JRE/bin/java"
fi

if [ -z "$JAVA_BIN" ] || [ ! -x "$JAVA_BIN" ]; then
  message "No JRE found. Please make sure \$IDEA_JDK, \$JDK_HOME, or \$JAVA_HOME point to valid JRE installation."
  exit 1
fi

Going by "eselect java-vm list", there's not even an option to set openjdk:11 as a system-wide VM.

A workaround for that problem is to create ${CONFIG_HOME}/JetBrains/IdeaIC2021.2/idea.jdk file with the path to JDK, but caveat is you'd have to do it each and every major update.

Proper fix should be replacing the line 

JDK="/opt/openjdk-bin-11" && [[ -d "/opt/openjdk-11" ]] && JDK="/usr/lib64/openjdk-bin-11"

with 

JRE="/opt/openjdk-bin-11" && [[ -d "/opt/openjdk-11" ]] && JRE="/usr/lib64/openjdk-bin-11"

Reproducible: Always
Comment 1 Mike Pagano gentoo-dev 2021-11-29 18:19:50 UTC
> 
> Going by "eselect java-vm list", there's not even an option to set
> openjdk:11 as a system-wide VM.

How about emerging openjdk:11 with the gentoo-vm use flag?

# eselect java-vm list

Available Java Virtual Machines:
  [1]   openjdk-11  system-vm
  [2]   openjdk-bin-8
Comment 2 Alex 2021-11-29 18:28:29 UTC
(In reply to Mike Pagano from comment #1)
> How about emerging openjdk:11 with the gentoo-vm use flag?

That might be an option, yea. Thanks for pointing that. But I don't want to update to Java 11 system-wide yet (it's still too immature IMO) and that's still a workaround - the real issue here is a hiccup in the launch script.
Comment 3 Mike Pagano gentoo-dev 2021-11-29 23:19:17 UTC
(In reply to Alex from comment #2)
> (In reply to Mike Pagano from comment #1)
> > How about emerging openjdk:11 with the gentoo-vm use flag?
> 
> That might be an option, yea. Thanks for pointing that. But I don't want to
> update to Java 11 system-wide yet (it's still too immature IMO) and that's
> still a workaround - the real issue here is a hiccup in the launch script.

I suggest you enable the gentoo-vm flag and then eselect java-vm set user <N> as appropriate, and you won't have this enabled system wide.
Comment 4 Alex 2022-05-10 20:03:59 UTC
Sorry, I missed the point where this issue was marked as "resolved" for some reason and now I'm encountering this again due to 2022.1 update. Should be fixed properly.

(In reply to Mike Pagano from comment #3)

> I suggest you enable the gentoo-vm flag and then eselect java-vm set user
> <N> as appropriate, and you won't have this enabled system wide.

I worded this wrong, my bad. I don't want to use Java 11 as any kind of "default", not as "system-vm" nor as "user-vm", but I need it for some (very few) programs. 

Gentoo allows this use-case: default system and user VM is Java 8, while a few programs can pick up Java 11 as they need it. IDEA can't due to the bug - it sets the wrong variable ("JDK" instead of "JRE") in the launch script. Proper fix is to patch this bug out.
Comment 5 Mike Pagano gentoo-dev 2022-05-10 20:37:59 UTC
(In reply to Alex from comment #4)
> Sorry, I missed the point where this issue was marked as "resolved" for some
> reason and now I'm encountering this again due to 2022.1 update. Should be
> fixed properly.
> 
> (In reply to Mike Pagano from comment #3)
> 
> > I suggest you enable the gentoo-vm flag and then eselect java-vm set user
> > <N> as appropriate, and you won't have this enabled system wide.
> 
> I worded this wrong, my bad. I don't want to use Java 11 as any kind of
> "default", not as "system-vm" nor as "user-vm", but I need it for some (very
> few) programs. 
> 
> Gentoo allows this use-case: default system and user VM is Java 8, while a
> few programs can pick up Java 11 as they need it. IDEA can't due to the bug
> - it sets the wrong variable ("JDK" instead of "JRE") in the launch script.
> Proper fix is to patch this bug out.

Did you try what I wrote above ?
Comment 6 Mike Pagano gentoo-dev 2022-05-10 20:39:09 UTC
(In reply to Mike Pagano from comment #5)
> (In reply to Alex from comment #4)
> > Sorry, I missed the point where this issue was marked as "resolved" for some
> > reason and now I'm encountering this again due to 2022.1 update. Should be
> > fixed properly.
> > 
> > (In reply to Mike Pagano from comment #3)
> > 
> > > I suggest you enable the gentoo-vm flag and then eselect java-vm set user
> > > <N> as appropriate, and you won't have this enabled system wide.
> > 
> > I worded this wrong, my bad. I don't want to use Java 11 as any kind of
> > "default", not as "system-vm" nor as "user-vm", but I need it for some (very
> > few) programs. 
> > 
> > Gentoo allows this use-case: default system and user VM is Java 8, while a
> > few programs can pick up Java 11 as they need it. IDEA can't due to the bug
> > - it sets the wrong variable ("JDK" instead of "JRE") in the launch script.
> > Proper fix is to patch this bug out.
> 
> Did you try what I wrote above ?

It sounds like you need a different way for Gentoo to handle java vm.
I suggest possibly describing your issue in a new bug for the java team
Comment 7 Alex 2022-05-11 15:00:18 UTC
> > Did you try what I wrote above ?

No, because that's not my point.

> It sounds like you need a different way for Gentoo to handle java vm.
> I suggest possibly describing your issue in a new bug for the java team

No, I don't have anything I can suggest to the Java team. I just want someone with write access to the Gentoo repo to fix the variable name in the launch script of IDEA, because that's what causing this incorrect behaviour.

That's it.

If you can't fix this issue, please don't mark it as "RESOLVED".
Comment 8 Alex 2022-05-11 15:06:07 UTC
Created attachment 778133 [details, diff]
Reqired fix
Comment 9 Mike Pagano gentoo-dev 2022-05-26 12:25:27 UTC
Maybe propose this upstream
Comment 10 Alex 2022-06-04 08:21:15 UTC
(In reply to Mike Pagano from comment #9)
> Maybe propose this upstream

I've chosen to propose it here. I even provided a patch.

Please, DO NOT CLOSE this issue UNLESS you fix it. Period.