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
/home/fede/.local/lilypond/lilypond-2.24.3/bin:/home/fede/.local/lilypond/lilypond-2.24.1/bin:/home/fede/.local/lilypond/lilypond-2.24.1/bin:/home/fede/.local/bin:/home/fede/bin:/usr/lib64/ccache:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin

Here’s my .bash_profile:

$ cat .bash_profile 
# .bash_profile

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

# 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
/home/fede/.local/lilypond/lilypond-2.24.3/bin:/home/fede/.local/bin:/home/fede/bin:/usr/lib64/ccache:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin

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.

The laptop also prints the right PATH now.

I was sure I restarted the system before checking. But now I think I used source .bash_profile, which seems to produce strange results: path duplications; paths still present even if removed between a source command and another.

The problem is how I used source, I guess.

1 Like