Skip to content

idea.sh should check for idea.jdk override file before setting IDEA_JDK (also, IDEA_CLASSPATH defunct)

Description:

IntelliJ IDEA supports downloading new JDKs and changing the boot runtime of the IDE in UI. This functions by setting the $XDG_CONFIG_HOME/JetBrains/IdeaIC2024.1/idea.jdk file, which overrides the JDK in use. However, due to the way the packaged idea.sh wrapper script sets IDEA_JDK, this config is ignored and the Arch OpenJDK (which lacks JCEF) will always be used until the user overrides IDEA_JDK themselves.

It makes sense for Arch to provide the OpenJDK as a default runtime, but it should not do so with higher precedence than a user-specified idea.jdk config setting.

See relevant script block from /usr/share/idea/bin/idea.sh:

if [ -n "$IDEA_JDK" ] && [ -x "$IDEA_JDK/bin/java" ]; then
  JRE="$IDEA_JDK"
fi

if [ -z "$JRE" ] && [ -s "${CONFIG_HOME}/JetBrains/IdeaIC2024.1/idea.jdk" ]; then
  USER_JRE=$(cat "${CONFIG_HOME}/JetBrains/IdeaIC2024.1/idea.jdk")
  if [ -x "$USER_JRE/bin/java" ]; then
    JRE="$USER_JRE"
  fi
fi

Tested-working patch: Not quite! See comment below

--- idea	2024-04-30 16:10:16.000000000 -0700
+++ idea.new	2024-06-18 13:49:15.607203419 -0700
@@ -1,5 +1,9 @@
 #!/bin/sh
 
+if [ -f "${XDG_CONFIG_HOME:-${HOME}/.config}/JetBrains/IdeaIC2024.1/idea.jdk" ]; then
+  exec /usr/share/idea/bin/idea.sh "$@"
+fi
+
 if [ -z "$IDEA_JDK" ] ; then
   IDEA_JDK="/usr/lib/jvm/java-17-openjdk/"
 fi

Aside: Pretty sure IDEA_CLASSPATH is defunct since this commit in 2021: https://github.com/JetBrains/intellij-community/commit/4f2e9b975436aed606a1a3f4e2fd1e56d3f34d94. File can be further simplified if the IDEA_JFX handling is removed.

Additional info:

  • Package version: extra/intellij-idea-community-edition 4:2024.1.1-1

Steps to reproduce:

  1. Install IntelliJ IDEA CE via package
  2. Run IntelliJ IDEA CE
  3. Observe that Help -> About shows boot runtime as OpenJDK 17
  4. Run Help -> Find Action... -> Choose Boot Java Runtime for the IDE...
  5. Choose a 21.x build with JCEF, allow it to download and unpack
  6. Choose Restart now to apply the change
  7. Observe that Help -> About shows boot runtime unchanged
Edited by Henry Tung
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information