Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overriding XDG_DATA_HOME in snap leads to multiple problems #237608

Open
LoicGrobol opened this issue Jan 9, 2025 · 11 comments
Open

Overriding XDG_DATA_HOME in snap leads to multiple problems #237608

LoicGrobol opened this issue Jan 9, 2025 · 11 comments
Assignees

Comments

@LoicGrobol
Copy link

Does this issue occur when all extensions are disabled?: Yes

Version: 1.97.0-insider
Commit: 9b0b13d
Date: 2025-01-08T05:06:32.681Z
Electron: 32.2.7
ElectronBuildId: 10660205
Chromium: 128.0.6613.186
Node.js: 20.18.1
V8: 12.8.374.38-electron.0
OS: Linux x64 6.12.8-1-MANJARO snap

2d28c0a added a feature that redefines XDG_DATA_HOME to be $SNAP_USER_DATA/.local/share. This leads to several problems

Would it be possible to revert this, or at least have an option to make it opt-out-able?

@LoicGrobol
Copy link
Author

ping @deepak1556 i guess

@LoicGrobol LoicGrobol changed the title Overriding XDG_DATA_HOME in snap lead to multiple problems Overriding XDG_DATA_HOME in snap leads to multiple problems Jan 9, 2025
@LoicGrobol
Copy link
Author

LoicGrobol commented Jan 9, 2025

A temporary fix for the terminal issues is to set "terminal.integrated.env.linux": {"XDG_DATA_HOME": "/home/<username>/.local/share"} in settings.

@iainlane
Copy link

iainlane commented Jan 14, 2025

Some other problems that I noticed were caused by this change

  • Locally installed fonts - in ${XDG_DATA_HOME}/fonts - stopped being found
  • neovim reconfigured itself
  • systemd tools don't see local units etc
  • podman downloads all containers again

the list goes on... Basically yes, please can you revert this part of the change? 🙏

The terminal workaround works for some of these, but not the fonts thing. For that one specifically, you can run as XDG_DATA_DIRS=${XDG_DATA_HOME}:${XDG_DATA_DIRS} code to stuff your home directory into the system one used by the snap.

@RafaelWO
Copy link

RafaelWO commented Jan 15, 2025

I have similar problems after I have switched from the .deb installation to snap (Ubuntu 24.04.1 LTS)


A temporary fix for the terminal issues is to set "terminal.integrated.env.linux": {"XDG_DATA_HOME": "/home/<username>/.local/share"} in settings.

The workaround from above works for me, thanks @LoicGrobol!

@p-himik
Copy link

p-himik commented Jan 18, 2025

Another example: executing podman run would result in the "container already exists" error even though any attempts to find that container would fail. Turns out, XDG_DATA_HOME was to blame and the suggested settings change fixes it.

Weirdly enough though, the env var was mentioning snap/code/180 initialy but according to strace, podman was actually using snap/code/176 for some reason. No clue why.

@jeckst
Copy link

jeckst commented Jan 23, 2025

I've been having issues with Jupyter notebooks in vscode (see here and here) with kernel definitions (which by default live in /home/<username>/.local/share/jupyter/… not being found, moving around and not being detected.

One of the symtoms I've seen was that jupyter kernelspec list gives different output based on whether I run it in the integrated terminal or in a standalone system terminal (see here).

Could someone here help me confirm that these are connected to this issue — could anyone recommend any way to check? Or should I create a separate issue for that?

@p-himik
Copy link

p-himik commented Jan 23, 2025

could anyone recommend any way to check?

You could try the suggested workaround and see if that fixes the issue on your side.

@jeckst
Copy link

jeckst commented Jan 23, 2025

@p-himik Yeah, I've done that and it does fix the output discrepancy within the terminals, but I don't expect it to fix the core problem of losing kernels in the notebooks, since that is not necessarily run by the terminal, I guess. And since that is an intermittent problem, it's not easy to dependably test anyway, so I am looking for some way to diagnose that this is the root cause of those issues.

@LoicGrobol
Copy link
Author

@jeckst It seems like it could be related at least! What led me to originally investigate this was uv virtual environments (which as this point some were in the snap tree and others in the regular home) jumping around. As in the list of available environments would change under my eyes while I was trying to select one. And it does look like jupyter uses the xdg path env variables (through platformdirs) in kernelspec. I guess you could set JUPYTER_*_DIR to their locations in your home when invoking vscode? I don't think it would overwrite them.

@jeckst
Copy link

jeckst commented Jan 23, 2025

@LoicGrobol Thanks for the pointers, I will try that

@cas--
Copy link

cas-- commented Feb 16, 2025

I encountered this with missing Atuin shell history in VSCode snap with a suggestion to create a link for Atuin, the same as Monospace fonts not working, however that seemed like a band aid and now can see it a much bigger issue.

Thanks @LoicGrobol for terminal workaround, a slight tweak to use $HOME env var would match usual env var setting:

  "terminal.integrated.env.linux": {
    "XDG_DATA_HOME": "${env:HOME}/.local/share"
  }

@deepak1556 Is preserve sys vars feature, implemented in #185834, working as expected? My reading of the change suggested that under snap vscode the terminals would revert to original env vars but I don't see that happening:

$ echo $XDG_DATA_HOME
~/snap/code/182/.local/share
$ echo $XDG_DATA_HOME_VSCODE_SNAP_ORIG
<empty>
$ echo $XDG_DATA_DIRS
~/snap/code/182/.local/share/flatpak/exports/share:~/snap/code/182/.local/share:~/snap/code/182:/snap/code/182/usr/share:/usr/share/ubuntu:/usr/share/gnome:~/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop:~/.nix-profile/share:/nix/var/nix/profiles/default/share:~/.nix-profile/share:/nix/var/nix/profiles/default/share:~/.nix-profile/share:/nix/var/nix/profiles/default/share
$ echo $XDG_DATA_DIRS_VSCODE_SNAP_ORIG 
/usr/share/ubuntu:/usr/share/gnome:~/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop:~/.nix-profile/share:/nix/var/nix/profiles/default/share

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants