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

XDG_DATA_DIRS is not set on fish shell #3109

Closed
qlem opened this issue Sep 17, 2019 · 31 comments · Fixed by #4575
Closed

XDG_DATA_DIRS is not set on fish shell #3109

qlem opened this issue Sep 17, 2019 · 31 comments · Fixed by #4575

Comments

@qlem
Copy link

qlem commented Sep 17, 2019

Linux distribution and version

5.2.14-arch2-1-ARCH - x86_64 GNU/Linux

Flatpak version

Flatpak 1.4.2

Description of the problem

XDG_DATA_DIRS is not set on fish shell. No desktop entry appears after install an app.

Steps to reproduce

Use fish shell as default shell, install flatpak then an app.

@TingPing
Copy link
Member

TingPing commented Sep 17, 2019

I've been using fish for years and Flatpaks dirs have always been picked up.

@refi64
Copy link
Collaborator

refi64 commented Sep 18, 2019 via email

@qlem
Copy link
Author

qlem commented Sep 18, 2019

You need to reboot once when you first install Flatpak

I just tried, doesn't work. I have reboot after Flatpak install and after app install too. $XDG_DATA_DIRS is still not defined.

$> echo $XDG_DATA_DIRS
/usr/local/share:/usr/share

I have to update $XDG_DATA_DIRS myself.

@Poorchop
Copy link

I was getting an error about both /var/lib/flatpak/exports/share and /home/me/.local/share/flatpak/exports/share not being in the search path for XDG_DATA_DIRS so I added them both in my fish config. Somehow I still get an error about /home/me/.local/share/flatpak/exports/share still not being in the search path even though echo $XDG_DATA_DIRS returns /var/lib/flatpak/exports/share /home/me/.local/share/flatpak/exports/share /usr/share/xfce:/var/lib/flatpak/exports/share /home/me/.local/share/flatpak/exports/share:/usr/share.

@matthiasclasen
Copy link
Collaborator

The expected format is :-separated. Your XDG_DATA_DIRS seems to be partially space-separated.

@Poorchop
Copy link

That's because echo $PATH looks at the value of the variable in fish. I am setting the variable properly as far as I'm aware since fish takes a list of arguments separated by spaces, which it then separates with colons when exporting it.

@TingPing
Copy link
Member

Hmm, Actually I can reproduce this now... Eitherway this isn't a Flatpak bug, it was working and fish is somehow inheriting the env vars incorrectly.

@adaigre
Copy link

adaigre commented Jan 26, 2020

I've got the same problem on a Fedora 31 Workstation with KDE.
$XDG_DATA_DIRS is not propagated to fish. chsh -s /bin/bash solves the issue.

@doums
Copy link

doums commented Apr 15, 2020

I have the same problem using fish as login shell.

@MatthiasGrandl
Copy link

Uh so anyone got a solution without setting the variable themselves? Don't really want to chsh just because of this annoyance.

@corvore
Copy link

corvore commented May 6, 2020

Uh so anyone got a solution without setting the variable themselves? Don't really want to chsh just because of this annoyance.

I don't use a lot of flatpaks. So I've done some shims in the past. Basically make a file that runs the Flatpak named what you want it named in use/bin with a .desktop pointing to it in menus.

It's dumb but works.

@travankor
Copy link

Shouldn't someone report this on the fish tracker since it seems like a regression on their side?

@matwey
Copy link

matwey commented May 29, 2020

I would not say that this is an issue in fish.
Isn't there a better way to setup environment variables for a user session than just relying on /etc/profile.d/flatpak.sh (mind .sh suffix)?

@Vogtinator
Copy link

See also this discussion about /etc/profile and fish in sddm: sddm/sddm#879

It might be possible to add a hack into the session script, which uses /bin/sh to run the profile script and then read back the changed environment. That could cause some surprising behaviour though and might even break stuff further.

@travankor
Copy link

travankor commented May 29, 2020

Does this recently added command in fish help?

Isn't there a better way to setup environment variables for a user session than just relying on /etc/profile.d/flatpak.sh (mind .sh suffix)?

/etc/environment? But you have more limitations than /etc/profile.d, like no variable expansion.

If fish doesn't want to implement POSIX, shouldn't they advertise a way to setup system environment variables? I think if multiple third party projects have run into this issue before, then this indicates a usability issue in fish, at least.

@matwey
Copy link

matwey commented May 29, 2020

They advertise to use /etc/environment:
fish-shell/fish-shell#3665

@travankor
Copy link

travankor commented May 31, 2020

Still think this is an issue with fish in general. /etc/environment and login.defs are OS-specific, do not offer config snippets, and somewhat limited in general since it just reads KEY=VALUE, which is why profile.d is popular. What flatpak could do is have a fish-specific file in /usr/share/fish/vendor_conf.d.

@refi64
Copy link
Collaborator

refi64 commented Jun 4, 2020 via email

@PureTryOut
Copy link

This just happened to me. Flatpak desktop files have been showing up fine till a system update somewhere last week and now they don't anymore. According to the system package manager Flatpak hasn't been upgraded in the meantime so I'm not sure what changed.

@soredake
Copy link

soredake commented Nov 9, 2020

bass source /etc/profile as workaround

robbert-vdh added a commit to robbert-vdh/dotfiles that referenced this issue Nov 22, 2020
@sebastianwagner
Copy link

It could also to be a bug in debians patches for lxde-common / openbox-lxde-session debian #906288.
A solution could be https://bugs.launchpad.net/debian/+source/lxde-common/+bug/1905289

Also check raspians solution.

@RafalSkolasinski
Copy link

Just hit that on OpenSuse Tumbleweed. Couldn't really fix it until I found the solution in fish-shell/fish-shell#7485 (comment).

@AlienProber
Copy link

AlienProber commented Dec 6, 2020

Is this possibly related to my below issue?

#4005

@Pingger
Copy link

Pingger commented Oct 8, 2021

Can confirm this issue for
Manjaro 21.04
Fish 3.3.1

Full Info
Operating System: Manjaro Linux
KDE Plasma Version: 5.22.5
KDE Frameworks Version: 5.86.0
Qt Version: 5.15.2
Kernel Version: 5.13.19-2-MANJARO (64-bit)

Current workaround: chsh to /bin/bash

@Zlopez
Copy link

Zlopez commented Nov 9, 2021

This is still happening on Fedora 35 Kinoite when /bin/fish is set as default shell. No flatpak apps are displayed or searchable in menu.

After switching to /bin/bash this was fixed.

@smcv
Copy link
Collaborator

smcv commented Nov 10, 2021

If a fish user wants to contribute a tested snippet for fish's equivalent of profile.d, please open a merge request. I don't think any of the Flatpak maintainers use fish, so if fish users want better interop with Flatpak, we're relying on you to provide it.

What we would need is something equivalent to profile/flatpak.sh (used for bash and POSIX sh) and profile/flatpak.csh (used for tcsh and csh), but in fish syntax; plus code in Makefile.am to install it in the right place (again, the same as profile/flatpak.sh).

@robbert-vdh
Copy link

robbert-vdh commented Nov 10, 2021

I have this in my fish configuration which probably doesn't do quite the same thing as profile/flatpak.sh, but it should be a start (it also doesn't take into account alternative $XDG_DATA_HOMEs and things like that):

if command -vq flatpak
    set -ga fish_user_paths ~/.local/share/flatpak/exports/bin /var/lib/flatpak/exports/bin
    set -gx --path XDG_DATA_DIRS ~/.local/share/flatpak/exports/share
    for install_dir in (flatpak --installations)
        set -gxa XDG_DATA_DIRS $install_dir/exports/share
    end
end

If Flatpak were to provide a /usr/share/fish/vendor_conf.d/flatpak.fish that does something similar then everything should work great out of the box.

refi64 added a commit to refi64/flatpak that referenced this issue Nov 13, 2021
Technically, Fish users can already make this work using
https://github.com/edc/bass, but it's also nice to have this working on
an out-of-the-box Flatpak installation.

Fixes flatpak#3109.

Signed-off-by: Ryan Gonzalez <[email protected]>
alexlarsson pushed a commit that referenced this issue Nov 15, 2021
Technically, Fish users can already make this work using
https://github.com/edc/bass, but it's also nice to have this working on
an out-of-the-box Flatpak installation.

Fixes #3109.

Signed-off-by: Ryan Gonzalez <[email protected]>
@rohrschacht
Copy link

I have this in my fish configuration which probably doesn't do quite the same thing as profile/flatpak.sh, but it should be a start (it also doesn't take into account alternative $XDG_DATA_HOMEs and things like that):

if command -vq flatpak
    set -ga fish_user_paths ~/.local/share/flatpak/exports/bin /var/lib/flatpak/exports/bin
    set -gx --path XDG_DATA_DIRS ~/.local/share/flatpak/exports/share
    for install_dir in (flatpak --installations)
        set -gxa XDG_DATA_DIRS $install_dir/exports/share
    end
end

If Flatpak were to provide a /usr/share/fish/vendor_conf.d/flatpak.fish that does something similar then everything should work great out of the box.

I tested this snippet in my own config.fish, but it broke most of my system. The application launcher only showed flatpaks and no other programs anymore, and some applications crashed when logging in. The problem was that XDG_DATA_DIRS was empty before, and according to [1], when XDG_DATA_DIRS is empty, a default value of /usr/local/share/:/usr/share/ is assumed. After adding this to the variable, everything works really well for me now. This is the snippet I am now using in my config.fish:

if command -vq flatpak
    set -ga fish_user_paths ~/.local/share/flatpak/exports/bin /var/lib/flatpak/exports/bin
    set -gx --path XDG_DATA_DIRS /usr/local/share/ /usr/share/ ~/.local/share/flatpak/exports/share
    for install_dir in (flatpak --installations)
        set -gxa XDG_DATA_DIRS $install_dir/exports/share
    end
end

flatpak doesn't complain anymore, flatpaks are showing up in my application launchers, and the rest of my system is still working 👍

[1] https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

@smcv
Copy link
Collaborator

smcv commented Mar 21, 2022

@rohrschacht, please could you test the version of this that got merged in #4575 (https://github.com/flatpak/flatpak/blob/1.13.2/profile/flatpak.fish)? And if that doesn't work or has things wrong with it, please report a new issue rather than replying to a closed issue.

Suggestions on an issue should not be interpreted as official, reviewed or correct unless they have actually been merged into the codebase.

@dm17
Copy link

dm17 commented Jun 15, 2022

I guess there is an approve fix because this is closed? I just hit the issue. Is the solution from @rohrschacht above the final one?

@smcv
Copy link
Collaborator

smcv commented Jun 15, 2022

If the version of this that is included in Flatpak releases is wrong, please report a new issue. Please do not reply to an issue that has been closed.

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

Successfully merging a pull request may close this issue.