RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1667008 - Duplicate user PATH entries in $PATH
Summary: Duplicate user PATH entries in $PATH
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: bash
Version: 8.0
Hardware: Unspecified
OS: Linux
unspecified
low
Target Milestone: rc
: 8.0
Assignee: Siteshwar Vashisht
QA Contact: Karel Volný
URL:
Whiteboard:
Depends On: 1652639
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-01-17 08:41 UTC by Siteshwar Vashisht
Modified: 2021-01-05 11:01 UTC (History)
2 users (show)

Fixed In Version: bash-4.4.19-12.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 1652639
Environment:
Last Closed: 2020-11-04 02:10:39 UTC
Type: Bug
Target Upstream Version:
Embargoed:
kdudka: needinfo-


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2020:4586 0 None None None 2020-11-04 02:10:41 UTC

Description Siteshwar Vashisht 2019-01-17 08:41:31 UTC
+++ This bug was initially created as a clone of Bug #1652639 +++

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.

--- Additional comment from Siteshwar Vashisht on 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.

--- Additional comment from Chris Tao on 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.

--- Additional comment from Siteshwar Vashisht on 2019-01-10 09:09:19 UTC ---

Review please https://src.fedoraproject.org/rpms/bash/pull-request/10 ?

--- Additional comment from Fedora Update System on 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 8 errata-xmlrpc 2020-11-04 02:10:39 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (bash bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:4586


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