flathub / com.jetbrains.IntelliJ-IDEA-Ultimate

https://flathub.org/apps/details/com.jetbrains.IntelliJ-IDEA-Ultimate
15 stars 8 forks source link

Would it be possible to not share the IntelliJ config with the host? #9

Closed devurandom closed 5 years ago

devurandom commented 5 years ago

Would it be possible to not share the IntelliJ config with the host? Since some things have to be setup specially inside the container (e.g. paths to binaries, terminal, ...), having the same config for both environments seems impossible. I assume it would be cleaner if the configs were separated.

See-Also: https://youtrack.jetbrains.com/issue/IDEA-189485#focus=streamItem-27-3238075-0-0

x80486 commented 5 years ago

Would it be possible to not share the IntelliJ config with the host?

I don't fully understand this one. What config(s) are you referring to?

devurandom commented 5 years ago

For example the list of JDKs. On my host it resides in /usr/lib/jvm/java-11, which is how I have it set up in IntelliJ. In the Flatpak container there is no JDK at that path, but IntelliJ still tries to use that path -- I assume because it uses the host IntelliJ's config.

This also affects paths to binaries, like Git or Hg.

TingPing commented 5 years ago

Can you stop opening issues that all ask the same thing.

No, Flatpaks do not use host state, host programs, or host configs. They are self contained sandboxed environments.

devurandom commented 5 years ago

Can you stop opening issues that all ask the same thing.

I transferred my questions from JetBrains' YouTrack to here as requested by @x80486: https://youtrack.jetbrains.com/issue/IDEA-189485#focus=streamItem-27-3238833-0-0

No, Flatpaks do not use host state, host programs, or host configs. They are self contained sandboxed environments.

How come the paths to binaries and the paths to JDKs appear in both my host's IntelliJ installation and the container started with Flatpak?

TingPing commented 5 years ago

How come the paths to binaries and the paths to JDKs appear in both my host's IntelliJ installation and the container started with Flatpak?

I'm not sure what you mean. If you are talking about the host path its because this package has host filesystem access. That is mostly a hack to be remotely useful and will hopefully go away once we have a sandbox friendly solution to directory access.

TingPing commented 5 years ago

I do agree this is a better forum to discuss it than jetbrains tracker, but maybe lets keep it in one issue and lets keep the topic to be: "I want more tools" and not "lets use host stuff" because the latter is not going to happen.

devurandom commented 5 years ago

How come the paths to binaries and the paths to JDKs appear in both my host's IntelliJ installation and the container started with Flatpak?

I'm not sure what you mean. If you are talking about the host path its because this package has host filesystem access. That is mostly a hack to be remotely useful and will hopefully go away once we have a sandbox friendly solution to directory access.

I am not sure what is going on, since I do not know how neither Flatpak nor IntelliJ work internally. But what I see is that I set paths to e.g. Git or Mercurial in my host InteliJ config and the same settings appear in the Flatpak container. The same can be observed for the JDK: Its path was set to /usr/lib/jvm/java-11 on the host. When I started the Flatpak container, the same path was set there, but it did not work, because there was no JDK at that location in the container. So I changed the path to /run/host/usr/lib/jvm/java-11-{...} and it worked. When I started the host's IntelliJ, that one stopped to work, though, because it was now using the same path, which did not exist on the host. My conclusion was that the two must be sharing their config.

[...] lets keep the topic to be: "I want more tools" and not "lets use host stuff" because the latter is not going to happen.

"Let's use host stuff" was my initial idea on how to get access to more tools quickly, without having to package them all in Flatpaks. I understood that it is not possible / desired, because of possible incompatibilities between the host and the container. Hence I do not intend to follow that thought any further.

TingPing commented 5 years ago

But what I see is that I set paths to e.g. Git or Mercurial in my host InteliJ config and the same settings appear in the Flatpak container. The same can be observed for the JDK: Its path was set to /usr/lib/jvm/java-11 on the host. When I started the Flatpak container, the same path was set there, but it did not work, because there was no JDK at that location in the container

So it probably stores two configs; A "global" config and a "project" config. The latter being used by both makes complete sense. If however these are global configs then this is an IntelliJ bug. It should be storing those in XDG_CONFIG_HOME but it sounds like it hardcoded a path to something else.

x80486 commented 5 years ago

You would need to "register" the SDKs first; whatever you have in that list is going to be used later on. Currently, IntelliJ IDEA does not store anything (relevant) in XDG_CONFIG_HOME, but it creates a $HOME/.IntelliJIdeaYYYY.N directory, and shovels everything in there.

You need to be aware that you can have settings at project level, and some others at application level.


Damn, now I understand what you say: you have two versions of the IDE, the Flatpak one and another one that you previously had installed. So yes, depending on the versions you have, both might be using the $HOME/.IntelliJIdeaYYYY.N directory; that's specified by the YYYY.N string.

By the way, there are some issues opened/closed in YouTrack to start using the Freedesktop XDG base directory standard — the first one dates around 10 years ago 😜. That would solve your problem.

Another (not so) "dirty workaround" would be to custom set the path where IntelliJ IDEA is reading/storing stuff for your non-Flatpak install — since that's the only one you can control. The file would be: /path/to/your/idea-IU/bin/idea.sh. Change all references from .IntelliJIdeaYYYY.N to something else and that should use that "something else". Keep in mind you would have to reset that between upgrades.

I'll close this one since it's not possible.

devurandom commented 5 years ago

I am using the same version of IntelliJ with Flatpak and on the host (using the JetBrains Toolbox). Is there really no way to not mount the host's config directory into the container? For other apps so far I had to manually move stuff from ~/.config to ~/.var/app/XXX/config in order for the configuration of the host application to show up in the container. IntelliJ was the first were the config was shared, hence this ticket.

TingPing commented 5 years ago

We just established it doesn't use ~/.config so it already does use the host config, which we also established why thats an obviously broken thing to do.

devurandom commented 5 years ago

I understand that both of you obviously know how this works, but I have to piece it together from your comments and then do some guesswork to fill in the gaps. What I suspect after your latest comment is that Flatpak mounts the whole of $HOME except ~/.config into the container?

So as long as IntelliJ does not store its config in ~/.config, the Flatpak runtime has no generic way of not mounting the config into the container (a way that would work independently of the application). And the Flatpak runtime also provides no way to exclude specific folders in $HOME for a certain Flatpak. Is that why "it's not possible"?

x80486 commented 5 years ago

If the application in question obeys the Freedesktop XDG base directory standard, when Flatpak'ed, it will use this location: $HOME/.var/app/$FLATPAK_ID — being $FLATPAK_ID, in this case, com.jetbrains.IntelliJ-IDEA-Ultimate. Bottom line, the "home" for Flatpak configs are $HOME/.var/app/ instead of $HOME. So every Flatpak has its own "XDG home".

IntelliJ IDEA does not obey that standard, so it doesn't use any of the XDG siblings; they put stuff somewhere: $HOME/.IntelliJIdeaYYYY.N. That location is referenced and accessible as-is for both: the Flatpak version and the one you installed via the Toolbox, hence you can share stuff between the installs. When/If they start using the Freedesktop XDG base directory standard, the Flatpak settings will be stored in $HOME/.var/app/com.jetbrains.IntelliJ-IDEA-Ultimate/, and the ones that you have from the Toolbox will be at $HOME — separated altogether, not sharing, everyone happy!

Again, what you are trying to do here is not possible unless you do some Jujitsu on the file that I told you before. Once they start using the Freedesktop XDG base directory standard, your wish will be granted, but not in this Christmas 🤣

devurandom commented 5 years ago

Again, what you are trying to do here is not possible unless you do some Jujitsu on the file that I told you before. Once they start using the Freedesktop XDG base directory standard, your wish will be granted, but not in this Christmas rofl

:D

Thank you for this information. With that background I had a look at the (sadly rather sparse) Flatpak documentation. I am wondering whether following flatpak run arguments might help:

The former results in a tmpfs being mounted in the IntelliJ configuration directory, while the latter does not have any effect when $HOME is also mounted (the documentation explains the effects of --persist with the condition "If the application doesn't have access to the real homedir, ..." and tests confirm this). Thus I confirm that it is (currently) not possible and open a bug report / feature request against Flatpak: flatpak/flatpak#2485.

Thanks a lot for your help and the explanations!

x80486 commented 4 years ago

Just some heads up about this subject...this should be coming in version 2020.1 according to this ticket.