98

For example, in Ubuntu, there is always a .local directory in the home directory and .profile includes this line:

PATH="$HOME/bin:$HOME/.local/bin:$PATH"

$HOME/.local/bin does not exist by default, but if it is created it's already in $PATH and executables within can be found.

This is not exactly mentioned in the XDG directory specification but seems derived from it.

What I wonder is if this is common enough that it could be usually assumed to exist in the most common end user distributions. Is it, for instance, in all of the Debian derivatives, or at least the Ubuntu ones? How about the Red Hat/Fedora/CentOS ecosystem? And so on with Arch, SUSE, and what people are using nowadays.

To be extra clear, this is only for $HOME/.local/bin, not $HOME/bin.

Out of curiosity, feel free to include BSDs, OS/X and others if you have the information. :)

8
  • 1
    I don't have it in my path, and I certainly won't put it there. (Debian, but xdm/fvwm, neither Gnome nor KDE as desktop).
    – dirkt
    Commented Oct 16, 2016 at 16:51
  • 1
    I checked for a system which might have it. None of my development accounts use bash, and packagers simply aren't thorough enough to notice unless I make a special check (see newpath). Commented Oct 16, 2016 at 16:57
  • 2
    IIRC Ubuntu's /etc/skel/.profile up to and including at least 14.04 tests for the presence of a user's $HOME/bin and adds it to the PATH if it exists; in contrast, 16.04 appears to add both $HOME/bin and $HOME/.local/bin unconditionally. I don't recall earlier Ubuntus adding $HOME/.local/bin at all - but I don't see anything relevant in the bash package changelog (which supposedly owns /etc/skel/.profile). Commented Oct 16, 2016 at 19:08
  • 1
    @steeldriver Interestingly, Ubuntu 17.04 does not have $HOME/.local/bin added to PATH by default.
    – edwinksl
    Commented Jul 5, 2017 at 17:09
  • 2
    TIL Ubuntu (20.04) does have ~/.local/bin in /etc/skel/.profile — but that doesn't help if you version your dot files & re-install them into all new accounts for decades on end. Thus, I've been manually adding it (PATH=~/.local/bin:"$PATH"), ever since starting python stuff (initially very surprised that python ecosystem chose to use a hidden ~/.local/ for binaries🤷‍♂️)
    – michael
    Commented May 20, 2020 at 7:14

2 Answers 2

94

The ~/.local directories are part of the systemd file-hierarchy spec and is an extension of the xdg-user-dirs spec.

It can be confusing as Debian-derived packages for bash lost the ~/.local path when they rebased to Bash 4.3. They did have it in Bash 4.2.

It is a bug, and a patch has been sitting in the Debian system for a bit now.

This bug is the reason Ubuntu 16.04 had ~/.local in the path and Ubuntu 17.04 did not.

If you run systemd-path as a user, you will see that it is intended to be in the path.

$ systemd-path user-binaries
/home/foo/.local/bin

In theory, the answer to your query is: Any distro that uses systemd or wants to maintain compatibility with systemd.

There is more information in file-hierarchy(7).

7
  • 1
    Thanks! Out of pure curiosity, was this also the case during upstart times? Only asking because my memory says it was there earlier than systemd, but it's equally likely I just misremember it!
    – Stoffe
    Commented Sep 18, 2017 at 3:12
  • 2
    I'd doubt it was before systemd, forever the convention was ~/bin.
    – pfalcon
    Commented Jan 14, 2018 at 16:29
  • Arrgh, this bug seems to have also arrived in 16.04 courtesy of a backported bash 4.3
    – Adrian
    Commented Apr 5, 2018 at 14:58
  • 2
    Works in Ubuntu 18.04.
    – Daniel
    Commented Jul 1, 2018 at 20:01
  • 1
    Debian Bullseye here – neither bash nor fish load ~/.local/bin into PATH. I needed to add it manually to ~/.profile for bash and for fish I added it this way: set -U fish_user_paths $HOME/.local/bin/ $fish_user_paths. Commented Feb 5, 2021 at 14:29
8

On RPM based distributions, the situation seems to look like this:

  • RHEL 7 - does add it to the end of PATH when you use a login shell. It will work with sudo su -l johndoe but it will not work if you do not use the -l switch.
  • CentOS 7 - see RHEL, it is always following RHEL.
  • Fedora 28 (probably older too) - same as RHEL/CentOS, added to the end of PATH

As for other distributions:

If you want to see those bugs sorted, please do not forget to vote/comment on those as this would highlight the importance of the issue.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .