List of paths to executables is not updated

This is driving me crazy. echo $PATH keeps returning a path - /home/fede/.local/lilypond/lilypond-2.24.1/ - which exists but it’s no longer present in the PATH defined in .bash_profile. You can see also repeated paths here:

$ echo $PATH

Here’s my .bash_profile:

$ cat .bash_profile 
# .bash_profile

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

# User specific environment and startup programs

# Percorso ai binari ufficiali di LilyPond
export PATH=$HOME/.local/lilypond/lilypond-2.24.3/bin:$PATH

I found many similar issues on the Internet, for example this one, and the general recommendation is running hash -r to clear the bash cache. This is not working though.

What I’m missing?

Check your ~/.bashrc and files in the /etc/profile.d/ directory to see if your PATH is set there. Your /etc/profile and /etc/bashrc are also sourced when you log in and you can check those if you made any changes there.

1 Like

Not found:

$ grep lilypond .bashrc /etc/profile.d/* /etc/profile /etc/bashrc 

It’s definitely a cache issue, I think.

Bash caches the full path to a command, but I don’t think it caches environment variables between sessions. It has to be set somewhere, whether by bash itself or inherited from somewhere. There are some suggestions in this thread:

1 Like

Logging in also sources /etc/environment I think.

Well, after restarting the session I see that the PATH is now correct on my PC at work running Fedora Workstation:

$ echo $PATH

Tonight I’ll check my laptop running Silverblue, as I had the same problem there.

It does, and for the complete graphical session and not just for the shell session.
man environment has the details.