PyCharm doesn't remember projects

I don't understand what is different when I run PyCharm in Gnome on my Ubuntu box, or whether I run it via the shell script (that toolbox created) via X11 remotely on my Windows machine.  They appear to both be using the same configuration directory, so I figured regardless of which way I run it, it would come up with the same projects loaded.  How can I reconcile this so that they both come up the same (I don't need them to run at the same time, just to share configurations).

I have the same issue with IntelliJ, presumably for the same reason.

Thanks!

11 comments
Comment actions Permalink

Hi, by default, the IDE uses the folder locations here to store setting/cache files. These folders should be the same if you use the same Linux user to launch the IDE.

If the user you use in the X11 remotely is not the same as the one that you use in your Gnome, please

* Use the same users in these two different ways.

* If you can't use the same user here, you could refer to here to configure files that independent of any user path.

You could also click `Help | Open Log in Editor` from the main menu, search the last idea.config.path to find your current IDE used setting/cache folders.

0
Comment actions Permalink

Lejia,

Thanks for the information!  They are using the exact same user.  Here's what I figured out: 

If I run IJ or PC from Gnome (on the Linux box directly) then it uses ~/projects/JetBrains/<product> but if I run IJ or PC from the command line it uses ~/.config/JetBrains/<product>.  All of my project directories (Java and Python) are in ~/projects but I'm not sure why running those from Gnome knows that but running from the command line doesn't.

So, I'm seeing these four directories:

From Gnome:
/home/sgartner/projects/JetBrains/PyCharmCE2021.1
/home/sgartner/projects/JetBrains/IntelliJIdea2021.1
From BASH:
/home/sgartner/.config/JetBrains/PyCharmCE2021.1
/home/sgartner/.config/JetBrains/IntelliJIdea2021.1

So, trying to follow the instructions linked above, I created a file in my home: ~/idea.properties with the single line:

idea.config.path=/home/sgartner/projects/JetBrains

Unfortunately, this only resulted in PyCharm acting like it was the first run and it created two folders in projects/JetBrains, "options" and "ssl" and one file, "port.lock".

I also tried:

idea.config.path=/home/sgartner/projects

This had the exact same result except the folders and files were created in the projects directory.  Now, obviously I can't set (and didn't try)  idea.config.path to "/home/sgartner/projects/JetBrains/PyCharmCE2021.1" as that will clearly not work for IJ and vice-versa.

So, while this looks like the right way to go, I don't quite understand how to make idea.properties work.

Thanks!

0
Comment actions Permalink

> From Gnome:
/home/sgartner/projects/JetBrains/PyCharmCE2021.1
/home/sgartner/projects/JetBrains/IntelliJIdea2021.1

Looks there are some settings in your IDEs that let the IDE use this path. Please click `Help | Edit Custom VM Options` and remove all `-Didea.xxx.path`. If it doesn't help, click the `Help | Show Log in ...` and upload the log here https://uploads.jetbrains.com/ , and share us the upload id here.

It might better to let the IDE use the default instead of these folders.

> idea.config.path=/home/sgartner/projects/JetBrains

You need to use the configuration in below if you want to configure it:

idea.config.path=/home/sgartner/projects/JetBrains/IntelliJIdea2021.1/config
idea.system.path=/home/sgartner/projects/JetBrains/IntelliJIdea2021.1/system
idea.plugins.path=/home/sgartner/projects/JetBrains/IntelliJIdea2021.1/config/plugins

idea.log.path=/home/sgartner/projects/JetBrains/IntelliJIdea2021.1/system/log

0
Comment actions Permalink

Lejia,

My real question is, why didn't changing the ~/idea.properties to set the base folder work?  I don't care if that base folder is ".config" or "projects," as long as both methods of launching IJ and PC are using the same one.

These are the VM options I have for PyCharm.  There is only one with the pattern you requested, "idea.plugins.path" and that path doesn't contain the "projects" directory, so I don't know how it got set or why:

-Xms128m
-Xmx1265m
-XX:ReservedCodeCacheSize=512m
-XX:+UseG1GC
-XX:SoftRefLRUPolicyMSPerMB=50
-XX:CICompilerCount=2
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-ea
-Dsun.io.useCanonCaches=false
-Djdk.http.auth.tunneling.disabledSchemes=""
-Djdk.attach.allowAttachSelf=true
-Djdk.module.illegalAccess.silent=true
-Dkotlinx.coroutines.debug=off
-Dsun.tools.attach.tmp.only=true
-Dide.no.platform.update=true
-Dtoolbox.notification.token=DIXDAixAtqSjx-afsJYMZC58Blwqb8vfmIZrmbTQk2Q=
-Dtoolbox.notification.portFile=/home/sgartner/.local/share/JetBrains/Toolbox/apps/PyCharm-C/ch-0/211.7628.24.vmoptions.port
-Didea.plugins.path=/home/sgartner/.local/share/JetBrains/Toolbox/apps/PyCharm-C/ch-0/211.7628.24.plugins

I validated that the VM options are identical regardless of which way the application is run.

0
Comment actions Permalink

Lejia,

I generated logs from PyCharm after running the two different ways.  I went through them and removed any project names.  The folder that it is using shows up pretty early in the log file with no mention previous to that.

Upload id: 2021_07_06_LWkTGTAnQQfuzQ69 (file: Logs for JetBrains.zip)

Also, it looks like in my comments above I reversed the path being used by the two methods.  It probably doesn't matter which is which since it's the dichotomy that's the problem, but these log files are named correctly.

Thanks!

0
Comment actions Permalink

Please run echo $IDEA_PROPERTIES , echo $PYCHARM_PROPERTIESecho $HOME, and echo $XDG_CONFIG_HOME
 these four commands in these two environment's Terminal to see if there is any difference.

Is there any difference?

I haven't seen any suspicious things from your log. These two different environments should use the same config folders.

I guess some environment variables might different when running in X11 remotely causing this issue.

0
Comment actions Permalink

There are no differences in those four values, below are the values.  I ran each set in the terminal of PyCharm when running in the two "modes".

XDG_CONFIG_HOME=/home/sgartner/projects
HOME=/home/sgartner

Neither of the _PROPERTIES variables were set.

So, I compared the entire environment between the two instances, looking for something to go on.  The environment running from Gnome is much larger than the one from BASH.  There were only a few that were in both and had different values. I doubt this is useful, but I figured I'd share the differences.  I looked in the BASH script for running PyCharm and nothing in there seems dynamically generated (not sure why I had to use a command in PyCharm to "generate" it), so I assume I'm running the same script you have, though there is no version number in the file.

DISPLAY=
    BASH: localhost:12.0
    Gnome: :1

SHLVL=
    BASH: 5
    Gnome: 1

XDG_DATA_DIRS=
    BASH: /usr/local/share:/usr/share:/var/lib/snapd/desktop
    Gnome: /usr/share/ubuntu:/usr/local/share/:/usr/share/

XDG_SESSION_TYPE=
    BASH: tty
    Gnome: x11

The following values were only set for Gnome:
DESKTOP_SESSION=ubuntu
DESKTOP_STARTUP_ID=gnome-shell/PyCharm Community/3196-30-UbuntuDev_TIME515842770
GDMSESSION=ubuntu
GIO_LAUNCHED_DESKTOP_FILE=/home/sgartner/.local/share/applications/jetbrains-pycharm-ce.desktop
GIO_LAUNCHED_DESKTOP_FILE_PID=139656
GJS_DEBUG_OUTPUT=stderr
GJS_DEBUG_TOPICS=JS ERROR;JS LOG
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
GNOME_SHELL_SESSION_MODE=ubuntu
GPG_AGENT_INFO=/run/user/1000/gnupg/S.gpg-agent:0:1
GTK_MODULES=gail:atk-bridge
IM_CONFIG_PHASE=1
INVOCATION_ID=cc9f6e60c5844aa682518c59a6351621
JOURNAL_STREAM=8:46097
MANAGERPID=1817
QT_ACCESSIBILITY=1
QT_IM_MODULE=ibus
SESSION_MANAGER=local/UbuntuDev:@/tmp/.ICE-unix/3182,unix/UbuntuDev:/tmp/.ICE-unix/3182
USERNAME=sgartner
WINDOWPATH=2
XAUTHORITY=/run/user/1000/gdm/Xauthority
XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg
XDG_CURRENT_DESKTOP=ubuntu:GNOME
XDG_MENU_PREFIX=gnome-
XDG_SESSION_DESKTOP=ubuntu
XMODIFIERS=@im=ibus

The following values were only set for BASH:
MOTD_SHOWN=pam
OLDPWD=/home/sgartner/projects
PS1=\[ $(printf "%$((COLUMNS-1))s" "")\r\]\$
SSH_CLIENT=192.168.1.41 52332 22
SSH_CONNECTION=192.168.1.41 52332 192.168.1.167 22
SSH_TTY=/dev/pts/2
TERM_SESSION_ID=b3f66bd4-89e2-484d-8c5b-52832d5a6542
XDG_SESSION_ID=207

Also, just for completeness, here is the contents of the .desktop file for PyCharm (/home/sgartner/.local/share/applications/jetbrains-pycharm-ce.desktop):
[Desktop Entry]
Name=PyCharm Community
Icon=/home/sgartner/.local/share/JetBrains/Toolbox/apps/PyCharm-C/ch-0/.icon.svg
StartupWMClass=jetbrains-pycharm-ce
Comment=The pure Python IDE
Exec="/home/sgartner/.local/share/JetBrains/Toolbox/apps/PyCharm-C/ch-0/211.7628.24/bin/pycharm.sh" %f
Version=1.0
Type=Application
Categories=Development;IDE;
Terminal=false
StartupNotify=true

 

0
Comment actions Permalink

XDG_CONFIG_HOME=/home/sgartner/projects might be the related cause.

This variable may only be configured in the shell but not in the graphical environment.

So when you using Gnome, your graphical environment (GUI) may doesn't have this variable configured.

And when you use the Toolbox (GUI) to launch the IDE, the IDE uses the default xdg config path: `~/.config`.

Please

* Refer to the guide here to https://help.ubuntu.com/community/EnvironmentVariables (Persistent environment variables section) to configure this variable (and related variables) for a graphical environment.
note: Shell config files such as ~/.bashrc~/.bash_profile, and ~/.bash_login are often suggested for setting environment variables. While this may work on Bash shells for programs started from the shell, variables set in those files are not available by default to programs started from the graphical environment in a desktop session.

* Or just remove this XDG_CONFIG_HOME and related variables to let your shell use the default config path.

0
Comment actions Permalink

Sorry if I wasn't clear, but there were no differences in those four values, below are the values.  I ran each set in the terminal of PyCharm when running in the two "modes".

XDG_CONFIG_HOME=/home/sgartner/projects
HOME=/home/sgartner

Neither of the _PROPERTIES variables were set.

So, to clarify, these four values were *identical* between Gnome and BASH.

 

0
Comment actions Permalink

However, unsetting that environment variable did change which config PyCharm used, so that was the culprit, but I don't know why it didn't also change it when running under Gnome.

So, to be clear, this works!

unset XDG_CONFIG_HOME ; PyCharm

Thanks for all the help!

0
Comment actions Permalink

> Sorry if I wasn't clear, but there were no differences in those four values, below are the values.

It was clear to me before that these four values are the same in your cases.

Linux uses different environment variables for shell and graphic environment.

That is to say, the Terminal in Gnome (the same for Terminal in IDE) could use different environment variables than the GUI apps in Gnome.

For example, the environment variables in ~/.bashrc only work when you check it in the Shell but do not exist for GUI apps. You need to set the environment variables in some places ~/.profile to make it works for Shell and Gui apps.

I suspect that `XDG_CONFIG_HOME` is not set in your graphic environment (only available in the Shell) so the IDEA uses a different config.

You could check the guide here to compare the environment variables in Shell vs graphic environment before unset XDG_CONFIG_HOME: https://askubuntu.com/a/356973

0

Please sign in to leave a comment.