From Fedora Project Wiki


User PATH Prioritization

Summary

Changing user PATH ~/.local/bin and ~/bin to be moved to the top of the PATH list instead of the end. This will bring Fedora in sync with other distributions which already fixed this issues (Debian/Ubuntu) and will make it easier for users to install and use their own command line tools, also fixing multiple bugs where user installed tools cannot be accessed because the system installed ones took precedence.

Owner

Current status

Detailed Description

Currently if user is installing their own tools with installers like (pip), they will be installed inside ~/.local/bin or ~/bin but if the same CLI tools are installed at system level the user would not be able to use his own tools because the system one would be picked instead. This happens because .bashrc file adds user PATH to the end instead of the top of PATH list variable.

Same problem was happening with other distributions but they fixed it (Debian bug #83915)

Example: "pip install --user virtualenv" would install virtualenv at user level, adding ~/.local/bin/virtualenv executable. Still, if virtualenv happens to be installed at system level, this would currently be used instead of user installed one. On the other hand, python itself already knows to prefer user installed modules which means that "python -m virtualenv" will call user installed module instead of the system one.

This may result in undefined behavior, where user installs foo, than run foo, but /usr/bin/foo is run and that import from Python modules in home. Those modules might have different API.

If we change the order and to assure the user folders do take precedence, we would assure that python modules and shell scripts would use the same modules, avoiding weird bugs where what you call is not what you installed.

The issue is not unique to pip installed and applies to any tools that are installed in de facto default XDG folder locations.

There should be no security concerns due to this change because any user is already able to add executables and to alter their own PATH, which means that if someone wants to trick a user to use another executable, they are already able to do that. This has already been proved several times in the initial discussions about this change.

The change itself technically is in /etc/skel/.bash_profile from bash.

Currently:

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

After the change:

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

Note that this change will only affect new user accounts, we cannot change PATH for already existing accounts without crazy and undesired hacks.

Benefit to Fedora

This change makes it possible for users to install and use tools at user level, without requiring them to hack their user PATH in order to be able to use them.

This bring Fedora in sync with other major Linux distributions which adopted the same path, prioritisation.

Scope

  • Proposal owners: change /etc/skel/.bash_profile to have local folders before the system ones in default PATH
  • Other developers: N/A (not a System Wide Change)
  • Release engineering: #7554 (a check of an impact with Release Engineering is needed)
  • Policies and guidelines: N/A (not a System Wide Change)
  • Trademark approval: N/A (not needed for this Change)

Upgrade/compatibility impact

N/A (not a System Wide Change)

How To Test

  1. pip install --upgrade --user virtualenv
  2. check that which virtualenv returns ~/.local/bin/virtualenv instead of another value like /usr/bin/virtualenv

There are no risk on breaking current deployments because this change would affect only newly created user accounts and nothing from default system installation would be installing tools at user level.


User Experience

This would bring a huge benefits for Python package creators which avoided promoting user of pip install --user <packagename> for the sole reason that the executable may not be picked. Almost all python tools that are installing CLI utilities do have at least one bug raised by a user that reported that the wrong tool version was used instead.

Dependencies

nope

Contingency Plan

  • Contingency mechanism: (What to do? Who will do it?) proposal owners revert the chnage
  • Contingency deadline: beta freeze
  • Blocks release? no
  • Blocks product? no

Documentation

TBD

Release Notes

Fedora now prioritizes commands from $HOME/.local/bin and $HOME/bin over system-wide paths to allow to easily mask system binaries with newer versions. For example pip install --user virtualenv will now work even when virtualenv from the package repositories is installed. The new behavior is only available for newly created user accounts.

  • Release Notes tracking: #186