42

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. :)

  • I've seen this question asked before, but haven't encountered a system which does this. To make the question topical rather than opinion, you might eliminate considerations of "common enough" and simply ask where it came from and examples of systems which do this for new user accounts. "Recent" Fedora does this, for example. – Thomas Dickey Oct 16 '16 at 16:41
  • I can reword to ask simply "which" do it, sure. It's a bit of a struggle to formulate the question since what I'm after is not any definite answer, but mostly a feel for if this can be reasonably assumed in most cases 2016. – Stoffe Oct 16 '16 at 16:48
  • 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 Oct 16 '16 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). – Thomas Dickey Oct 16 '16 at 16:57
  • 1
    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). – steeldriver Oct 16 '16 at 19:08
41

The ~/.local directories is 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 and 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)

  • 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 Sep 18 '17 at 3:12
  • I'd doubt it was before systemd, forever the convention was ~/bin. – pfalcon Jan 14 '18 at 16:29
  • Arrgh, this bug seems to have also arrived in 16.04 courtesy of a backported bash 4.3 – Adrian Apr 5 '18 at 14:58
  • Works in Ubuntu 18.04. – Daniel Jul 1 '18 at 20:01
1

On RPM based distros the situation seems to look like this

  • RHEL 7 - does add it to the end of PATH see https://bugzilla.redhat.com/show_bug.cgi?id=1583227 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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.