$HOME/.local/bin in shell PATH but not in global profile

According to the XDG Base Directory:

User-specific executable files may be stored in $HOME/.local/bin. Distributions should ensure this directory shows up in the UNIX $PATH environment variable, at an appropriate place.

It seems Fedora ensures this for bash but not for other shells (sh). As a consequence, applications like KDE’s krunner are then unable to launch commands when the executable is in that directory.

What would be the best way of file this as a Fedora bug? I am not sure which component is the relevant one.

It would, I believe, be the shell provider itself. bash, for example, provides /etc/skell/.bashrc, which defines this for bash.

Thank you.

However, I made a mistake in my original post. Krunner invokes indeed sh, but sh is just a symlink to /usr/bin/bash.

I assume this is a non-login shell, so the shell would not invoke a profile script. According to the indication that:

Bash non-login shells run only /etc/bashrc

probably this should be set (if appropriate) in /etc/bashrc. I will wait for some more feedback (if any) and then file a bug.

That would be a bug to change PATH in .bashrc. It’s only safe to change in .bash_profile. Becuase you cannot then override it in interactive sessions.
And indeed that ios where it’s being changed sigh…

$ sfind -f '.local/bin' 2>/dev/null 
./skel/.bashrc:9:  if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]; then
./skel/.bashrc:10:      PATH="$HOME/.local/bin:$HOME/bin:$PATH"

I wouldn’t argue about that, but see Bug 1615131 - ~/.local/bin isn’t in the default PATH for why it was moved from .bash_profile to .bashrc.

From https://src.fedoraproject.org/rpms/bash.git

+ git log 739b272e5f5d10cf27a847a44d09eb7f4b6ec89b~..739b272e5f5d10cf27a847a44d09eb7f4b6ec89b
commit 739b272e5f5d10cf27a847a44d09eb7f4b6ec89b
Author: Siteshwar Vashisht <svashisht@redhat.com>
Date:   Mon Sep 10 15:55:43 2018 +0200

    Set custom PATH in non-login shells

    .bash_profile is sourced only in login shells. Since .bash_profile
    sources .bashrc, it should be safe to set custom PATH in .bashrc.

    Resolves: #1615131
1 Like