Bug 1583227

Summary: ~/.local/bin is not added at the top of the user PATH even if is documented by systemd and XDG spec
Product: Red Hat Enterprise Linux 7 Reporter: Sorin Sbarnea <ssbarnea>
Component: bashAssignee: Siteshwar Vashisht <svashisht>
Status: CLOSED NOTABUG QA Contact: BaseOS QE - Apps <qe-baseos-apps>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.7-AltCC: jperrin, kdudka
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-05-28 15:10:27 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Sorin Sbarnea 2018-05-28 13:53:18 UTC
Description of problem:

Apparently RHEL does not respect the systemd specification which documents clearly the ~/.local/bin it is part of PATH.

https://www.freedesktop.org/software/systemd/man/file-hierarchy.html

How reproducible:
Always

Steps to Reproduce:
1. set |grep PATH

Actual results:
PATH=/usr/lib64/ccache:/sbin:/bin:/usr/sbin:/usr/bin

Expected results:
PATH=~/.local/bin:/usr/lib64/ccache:/sbin:/bin:/usr/sbin:/usr/bin

Additional info:

Note that this feature is not specific to destop usage and respecting it essential for many tools to work correctly.

For example when using pip to install modules at user level the executables will be installed inside ~/.local/bin, and because RHEL does not add them to path scripts running them would get broken.

This PATH is supposed to be appended at the start of the PATH list, not at the end, allowing users to override default tool to be used with the ones installed by themselves. 

Example: user wanting to use newer version of virtualenv, tox, pip, which is not available/provided by the operating system.

Comment 2 Siteshwar Vashisht 2018-05-28 14:09:15 UTC
It should be set by ~/.bash_profile on rhel 7. This is the default bash_profile:

$ cat ~/.bash_profile 
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

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

export PATH

Either you have modified ~/.bash_profile on your system or you are overriding PATH after ~/.bash_profile is sourced.

Comment 3 Sorin Sbarnea 2018-05-28 14:43:21 UTC
It was my mistake as I used su to change user and I forgot to use `-l` to specify the login. In that case the PATH is not updated and it does use the default, which does not include it.

One thing that I observed is that the user bin path is added to the end of the list and this could be problematic because if users installs his own tool, that tool will never be used as long there is one installed at system level.

I am not sure if the spec(s) do mention the precedence order of the PATHs as my impression is that user one should take precedence, allowing user-override.

Comment 5 Siteshwar Vashisht 2018-05-28 15:10:05 UTC
> One thing that I observed is that the user bin path is added to the end of the list and this could be problematic because if users installs his own tool, that tool will never be used as long there is one installed at system level.

It is already being discussed in fedora-devel[1].

[1] https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/OXXC5NOZP37W2F6GHV6P5E6K22QHOBNJ/

Comment 6 Sorin Sbarnea 2018-05-29 07:40:12 UTC
Thanks for posting the link to Fedora discussion. Apparently the discussion took place about 3 weeks ago and didn't get any clear outcomes. 

A small summary:
- Debian/Ubuntu now adds that to the top of the PATH, as expected.
- security concerns are irrelevant because any user can already alter PATH or create files on his own home directory.

Comment 7 Alexander Larsson 2020-03-09 09:32:11 UTC
*** Bug 1093432 has been marked as a duplicate of this bug. ***