PATH duplication on logout/login

If you have a bin directory such as ~/.login/bin or ~/bin the ~/.profile file will add that directory to the PATH when you login. If you logout and then login again the bin directory will again be added to the PATH.
You wind up with multiple entries in the PATH to the same directory.

1 Like

This may be due to what you are trying to achieve having a different preferred method.
Ultimately, what is your goal in having this directories? Maybe we can help you set up something that meets that goal, without the bug.

I did a little investigating in debian, ubuntu and fedora. Debian works the way it should but ubuntu removed three lines from /etc/profile which resets the PATH. Consequently any OS derived from ubuntu will add to the PATH every time you logout and back in. Fedora solved the problem checking the PATH to see if the additional PATH already exists.
Simple test to avoid the problem: [[ "$PATH" =~ "$HOME/.local/bin" ]]. If the directory exists in the PATH don't add it again when $HOME/.profile is executed on login.
Better yet fix /etc/profile to reset the PATH like debian does.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.