PyCharm won't start with runtime specified in PYCHARM_JDK

Hello,

 

I have the following issue which is annoying to say the least. I have Ubuntu 20.04 and PyCharm 2021.1.2

I'm using sdkman to manage different Java versions and when I open PyCharm using shortcut:

 

I always get this warning...

So I went ahead and switched to bundled runtime, so I did that, and I have my pycharm.jdk file 

 

internetmosquito@internetmosquito-PE72-7RD  ~/.config/JetBrains/PyCharm2021.2  cat pycharm.jdk
/home/internetmosquito/.jbr/jbr_nomod-11_0_11-linux-x64-b1504.8

 

I even went ahead and added those env variables PYCHARM_JDK and IDEA_JDK in my .zshrc file:

export PYCHARM_JDK="/home/internetmosquito/.jbr/jbr_nomod-11_0_11-linux-x64-b1504.8"
export IDEA_JDK="/home/internetmosquito/.jbr/jbr_nomod-11_0_11-linux-x64-b1504.8"

But regardless, I always get the warning. Funny thing is that if I start from a terminal, it will pick up the bundled runtime...so what do I need to do so when launching Pycharm from launcher it gets env variables properly?

Thanks!

6 comments
Comment actions Permalink

/home/internetmosquito/.jbr/jbr_nomod-11_0_11-linux-x64-b1504.8 - it's not a bundled JDK.

You should use the one that is in the PyCharm installation folder. See https://intellij-support.jetbrains.com/hc/en-us/articles/206544879-Selecting-the-JDK-version-the-IDE-will-run-under

0
Comment actions Permalink

Sergey Karpov That path is where PyCharm installed the bundled runtime...I just followed this steps in the same page you provided

 

 

  • Start the IDE, use Help | Find Action (Ctrl+Shift+A or Cmd+Shift+A on Mac), type "Choose Boot Java Runtime for the IDE", press Enter.
  • Select the version to install, the higher the number after b, the more recent is the version. It makes sense to install the most recent version or the version you were asked to try by JetBrains staff. Installing old runtime versions may render your IDE unusable or introduce new issues.
  • Click the OK button and wait until the file with JetBrains Runtime is downloaded and configured.

Why would you say it's not a bundled JDK?


EDIT: I just noticed in the same page they mention:

If you can't start the IDE to access this dialog or the runtime doesn't change, please see below for the platform specific instructions. You would need to remove the <product>.jdk file from the configuration directory and unset any environment variables that override the default runtime. If there is no jbr subdirectory in the IDE installation directory, reinstall the product.

 

Does that imply that the /.jbr folder has to be inside where PyCharm was "installed"...not that I really install anything in Linux though...

 

0
Comment actions Permalink

>Does that imply that the /.jbr folder has to be inside where PyCharm was "installed"...not that I really install anything in Linux though...

Correct, it's in the same folder as <PYCHARM_INSTALLATION>\bin
There should be a folder called jbr. Do you have it?

0
Comment actions Permalink

Sergey Karpov Hey,

 

I noticed there's one at the root of my pycharm directory:

/home/internetmosquito/Downloads/pycharm-2021.1.2/jbr

Contents:

internetmosquito@internetmosquito-PE72-7RD  ~/Downloads/pycharm-2021.1.2/jbr  ls -ltra
total 32
drwxrwxr-x 3 internetmosquito internetmosquito 4096 jun 11 01:02 include
drwxrwxr-x 4 internetmosquito internetmosquito 4096 jun 11 01:02 conf
drwxrwxr-x 64 internetmosquito internetmosquito 4096 jun 11 01:02 legal
-rw-rw-r-- 1 internetmosquito internetmosquito 1119 ago 12 01:15 release
drwxrwxr-x 7 internetmosquito internetmosquito 4096 ago 12 01:15 .
drwxrwxr-x 2 internetmosquito internetmosquito 4096 ago 12 01:15 bin
drwxrwxr-x 9 internetmosquito internetmosquito 4096 ago 12 01:15 lib
drwxrwxr-x 9 internetmosquito internetmosquito 4096 ago 12 01:15 ..

but nothing inside /bin

internetmosquito@internetmosquito-PE72-7RD  ~/Downloads/pycharm-2021.1.2/bin  ls -ltra
total 8820
-rw-rw-r-- 1 internetmosquito internetmosquito 2359 ago 12 01:15 appInfo.xml
-rwxrwxr-x 1 internetmosquito internetmosquito 5995 ago 12 01:15 pycharm.sh
-rw-rw-r-- 1 internetmosquito internetmosquito 408 ago 12 01:15 pycharm64.vmoptions
-rwxrwxr-x 1 internetmosquito internetmosquito 646 ago 12 01:15 printenv.py
-rw-rw-r-- 1 internetmosquito internetmosquito 2613 ago 12 01:15 log.xml
-rwxrwxr-x 1 internetmosquito internetmosquito 296 ago 12 01:15 inspect.sh
-rwxrwxr-x 1 internetmosquito internetmosquito 28392 ago 12 01:15 fsnotifier
-rwxrwxr-x 1 internetmosquito internetmosquito 808 ago 12 01:15 restart.py
-rw-rw-r-- 1 internetmosquito internetmosquito 10784 ago 12 01:15 pycharm.svg
-rw-rw-r-- 1 internetmosquito internetmosquito 10281 ago 12 01:15 pycharm.png
-rwxrwxr-x 1 internetmosquito internetmosquito 828 ago 12 01:15 ltedit.sh
-rw-rw-r-- 1 internetmosquito internetmosquito 359528 ago 12 01:15 libdbm64.so
-rw-rw-r-- 1 internetmosquito internetmosquito 10194 ago 12 01:15 idea.properties
-rwxrwxr-x 1 internetmosquito internetmosquito 221 ago 12 01:15 format.sh
-rw-rw-r-- 1 internetmosquito internetmosquito 95092 ago 12 01:15 brokenPlugins.db
-rw-rw-r-- 1 internetmosquito internetmosquito 8458240 ago 12 01:15 icons.db
drwxrwxr-x 2 internetmosquito internetmosquito 4096 ago 12 01:15 .
drwxrwxr-x 9 internetmosquito internetmosquito 4096 ago 12 01:15 ..

 

By the way I switched to it:

 

But upon restart I still get the same error...to me it's clear Pycharm just reads some env variable that overrides whatever I chose. I'll try to disable my JDK related env variables in .bashrc...just to see if they get read from there? It's clear that they're not read from .zshrc

0
Comment actions Permalink

Hi. Please check if there is any JDK related modifications in pycharm.sh?

0
Comment actions Permalink

Petr Rastegaev Sorry for late response

Here are the contents, I think this is the default and looking at it, makes sense

#!/bin/sh
# Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.

# ---------------------------------------------------------------------
# PyCharm startup script.
# ---------------------------------------------------------------------

message()
{
TITLE="Cannot start PyCharm"
if [ -n "$(command -v zenity)" ]; then
zenity --error --title="$TITLE" --text="$1" --no-wrap
elif [ -n "$(command -v kdialog)" ]; then
kdialog --error "$1" --title "$TITLE"
elif [ -n "$(command -v notify-send)" ]; then
notify-send "ERROR: $TITLE" "$1"
elif [ -n "$(command -v xmessage)" ]; then
xmessage -center "ERROR: $TITLE: $1"
else
printf "ERROR: %s\n%s\n" "$TITLE" "$1"
fi
}

if [ -z "$(command -v uname)" ] || [ -z "$(command -v realpath)" ] || [ -z "$(command -v dirname)" ] || [ -z "$(command -v cat)" ] || \
[ -z "$(command -v egrep)" ]; then
TOOLS_MSG="Required tools are missing:"
for tool in uname realpath egrep dirname cat ; do
test -z "$(command -v $tool)" && TOOLS_MSG="$TOOLS_MSG $tool"
done
message "$TOOLS_MSG (SHELL=$SHELL PATH=$PATH)"
exit 1
fi

# shellcheck disable=SC2034
GREP_OPTIONS=''
OS_TYPE=$(uname -s)
OS_ARCH=$(uname -m)

# ---------------------------------------------------------------------
# Ensure $IDE_HOME points to the directory where the IDE is installed.
# ---------------------------------------------------------------------
IDE_BIN_HOME=$(dirname "$(realpath "$0")")
IDE_HOME=$(dirname "${IDE_BIN_HOME}")
CONFIG_HOME="${XDG_CONFIG_HOME:-${HOME}/.config}"

# ---------------------------------------------------------------------
# Locate a JRE installation directory command -v will be used to run the IDE.
# Try (in order): $PYCHARM_JDK, .../pycharm.jdk, .../jbr, $JDK_HOME, $JAVA_HOME, "java" in $PATH.
# ---------------------------------------------------------------------
# shellcheck disable=SC2154
if [ -n "$PYCHARM_JDK" ] && [ -x "$PYCHARM_JDK/bin/java" ]; then
JRE="$PYCHARM_JDK"
fi

BITS=""
if [ -z "$JRE" ] && [ -s "${CONFIG_HOME}/JetBrains/PyCharm2021.2/pycharm.jdk" ]; then
USER_JRE=$(cat "${CONFIG_HOME}/JetBrains/PyCharm2021.2/pycharm.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
JRE="$IDE_HOME/jbr"
fi

# shellcheck disable=SC2153
if [ -z "$JRE" ]; then
if [ -n "$JDK_HOME" ] && [ -x "$JDK_HOME/bin/java" ]; then
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 \$PYCHARM_JDK, \$JDK_HOME, or \$JAVA_HOME point to valid JRE installation."
exit 1
fi

# ---------------------------------------------------------------------
# Collect JVM options and IDE properties.
# ---------------------------------------------------------------------
# shellcheck disable=SC2154
if [ -n "$PYCHARM_PROPERTIES" ]; then
IDE_PROPERTIES_PROPERTY="-Didea.properties.file=$PYCHARM_PROPERTIES"
fi

BITS="64"
VM_OPTIONS_FILE=""
USER_VM_OPTIONS_FILE=""
# shellcheck disable=SC2154
if [ -n "$PYCHARM_VM_OPTIONS" ] && [ -r "$PYCHARM_VM_OPTIONS" ]; then
# 1. $<IDE_NAME>_VM_OPTIONS
VM_OPTIONS_FILE="$PYCHARM_VM_OPTIONS"
elif [ -r "${IDE_HOME}.vmoptions" ]; then
# 2. <IDE_HOME>.vmoptions || <IDE_HOME>/bin/<bin_name>.vmoptions + <IDE_HOME>.vmoptions (Toolbox)
VM_OPTIONS_FILE="${IDE_HOME}.vmoptions"
if ! egrep -q -e "^-ea$" "${IDE_HOME}.vmoptions" && [ -r "${IDE_BIN_HOME}/pycharm${BITS}.vmoptions" ]; then
VM_OPTIONS_FILE="${IDE_BIN_HOME}/pycharm${BITS}.vmoptions"
USER_VM_OPTIONS_FILE="${IDE_HOME}.vmoptions"
fi
elif [ -r "${CONFIG_HOME}/JetBrains/PyCharm2021.2/pycharm${BITS}.vmoptions" ]; then
# 3. <config_directory>/<bin_name>.vmoptions
VM_OPTIONS_FILE="${CONFIG_HOME}/JetBrains/PyCharm2021.2/pycharm${BITS}.vmoptions"
else
# 4. <IDE_HOME>/bin/[<os>/]<bin_name>.vmoptions [+ <config_directory>/user.vmoptions]
if [ -r "${IDE_BIN_HOME}/pycharm${BITS}.vmoptions" ]; then
VM_OPTIONS_FILE="${IDE_BIN_HOME}/pycharm${BITS}.vmoptions"
else
test "${OS_TYPE}" = "Darwin" && OS_SPECIFIC="mac" || OS_SPECIFIC="linux"
if [ -r "${IDE_BIN_HOME}/${OS_SPECIFIC}/pycharm${BITS}.vmoptions" ]; then
VM_OPTIONS_FILE="${IDE_BIN_HOME}/${OS_SPECIFIC}/pycharm${BITS}.vmoptions"
fi
fi
if [ -r "${CONFIG_HOME}/JetBrains/PyCharm2021.2/user.vmoptions" ]; then
if [ -n "$VM_OPTIONS_FILE" ]; then
VM_OPTIONS="${CONFIG_HOME}/JetBrains/PyCharm2021.2/user.vmoptions"
else
USER_VM_OPTIONS_FILE="${CONFIG_HOME}/JetBrains/PyCharm2021.2/user.vmoptions"
fi
fi
fi

VM_OPTIONS=""
if [ -n "$VM_OPTIONS_FILE" ]; then
VM_OPTIONS=$(cat "$VM_OPTIONS_FILE" "$USER_VM_OPTIONS_FILE" 2> /dev/null | egrep -v -e "^#.*")
else
message "Cannot find VM options file"
fi

CLASSPATH="$IDE_HOME/lib/bootstrap.jar"
CLASSPATH="$CLASSPATH:$IDE_HOME/lib/util.jar"
CLASSPATH="$CLASSPATH:$IDE_HOME/lib/jna.jar"
# shellcheck disable=SC2154
if [ -n "$PYCHARM_CLASSPATH" ]; then
CLASSPATH="$CLASSPATH:$PYCHARM_CLASSPATH"
fi

# ---------------------------------------------------------------------
# Run the IDE.
# ---------------------------------------------------------------------
IFS="$(printf '\n\t')"
# shellcheck disable=SC2086
"$JAVA_BIN" \
-classpath "$CLASSPATH" \
${VM_OPTIONS} \
"-XX:ErrorFile=$HOME/java_error_in_pycharm_%p.log" \
"-XX:HeapDumpPath=$HOME/java_error_in_pycharm_.hprof" \
"-Djb.vmOptionsFile=${USER_VM_OPTIONS_FILE:-${VM_OPTIONS_FILE}}" \
${IDE_PROPERTIES_PROPERTY} \
-Djava.system.class.loader=com.intellij.util.lang.PathClassLoader -Didea.vendor.name=JetBrains -Didea.paths.selector=PyCharm2021.2 -Didea.platform.prefix=Python \
com.intellij.idea.Main \
"$@"

And again, if I run this from a zsh terminal, it works fine, the problem is when I start IDE from the launch menu at Ubuntu

0

Please sign in to leave a comment.