Bug 1652639 - Duplicate user PATH entries in $PATH
Summary: Duplicate user PATH entries in $PATH
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: bash
Version: 29
Hardware: Unspecified
OS: Linux
unspecified
low
Target Milestone: ---
Assignee: Siteshwar Vashisht
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 1667008
TreeView+ depends on / blocked
 
Reported: 2018-11-22 14:00 UTC by Chris Tao
Modified: 2019-01-19 02:26 UTC (History)
5 users (show)

Fixed In Version: bash-4.4.23-6.fc29
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1667008 (view as bug list)
Environment:
Last Closed: 2019-01-19 02:26:07 UTC
kdudka: needinfo-


Attachments (Terms of Use)

Description Chris Tao 2018-11-22 14:00:12 UTC
Description of problem:
Since https://src.fedoraproject.org/rpms/bash/c/739b272e5f5d10cf27a847a44d09eb7f4b6ec89b?branch=f29 , User PATH is prepended to $PATH every time ~/.bashrc is sourced. This includes the login phase and when the user runs bash inside the session. The result is two duplicate user PATH entries in $PATH, gets even more with nested bash sessions. 
This does no harm, but may confuse users.

Version-Release number of selected component (if applicable):
bash-4.4.23-5.fc29.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Open a graphical session with startx or a DM. In my case it's KDE/SDDM. Not tested on gdm/GNOME(Wayland)
2. Open a terminal emulator (must not use d-bus activation)
3. echo $PATH

Actual results:
$ echo $PATH
/home/username/.local/bin:/home/username/bin:/home/username/.local/bin:/home/username/bin:/usr/lib64/ccache:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin

Expected results:
There shouldn't be duplicate entries in $PATH.

Additional info:
Generally I think it's still better to set $PATH inside ~/.bash_profile. This should work for all applications inside the session's scope unit, as long as default shell is bash, but not for systemd user services.
Another partial fix for display managers is to check whether bash is interactive before sourcing ~/.bashrc in ~/.bash_profile, since /etc/X11/xinit/Xsession runs bash non-interactively.

Comment 1 Siteshwar Vashisht 2018-11-23 16:03:05 UTC
You can modify your .bashrc to:

if ! [[ $PATH =~ "$HOME/.local/bin:$HOME/bin:" ]]; then PATH="$HOME/.local/bin:$HOME/bin:$PATH"; fi

I will fix it through an update.

Comment 2 Chris Tao 2018-11-24 09:02:53 UTC
(In reply to Siteshwar Vashisht from comment #1)
> You can modify your .bashrc to:
> 
> if ! [[ $PATH =~ "$HOME/.local/bin:$HOME/bin:" ]]; then
> PATH="$HOME/.local/bin:$HOME/bin:$PATH"; fi
> 
> I will fix it through an update.

After modifying .bashrc and restarting bash, duplicate PATH is gone. 
Thank you for the fix.

Comment 3 Siteshwar Vashisht 2019-01-10 09:09:19 UTC
Review please https://src.fedoraproject.org/rpms/bash/pull-request/10 ?

Comment 4 Fedora Update System 2019-01-17 08:40:38 UTC
bash-4.4.23-6.fc29 has been submitted as an update to Fedora 29. https://bodhi.fedoraproject.org/updates/FEDORA-2019-9d006f6254

Comment 5 Fedora Update System 2019-01-18 03:36:22 UTC
bash-4.4.23-6.fc29 has been pushed to the Fedora 29 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-9d006f6254

Comment 6 Fedora Update System 2019-01-19 02:26:07 UTC
bash-4.4.23-6.fc29 has been pushed to the Fedora 29 stable repository. If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.