2

My PATH Prefixes Don't Persist

I'm using Fish v3.2.0. According to the documentation, set -U fish_user_paths should persistently ensure that the directories stored in it should be looked up before other items in the PATH. However, it's inheriting PATH from somewhere else (a parent shell? a startup file of some kind?) and the PATH only changes if I manually set things in each shell instance.

What Works (Temporarily)

> echo $PATH
/usr/bin /bin /usr/sbin /sbin /usr/local/opt/python@3.9/libexec/bin/python

This works, temporarily. It just doesn't persist.

> set -U fish_user_paths /usr/local/opt/python@3.9/libexec/bin > set -SL fish_user_paths $fish_user_paths: set in universal scope, unexported, with 1 elements $fish_user_paths[1]: |/usr/local/opt/python@3.9/libexec/bin|

> which -a python /usr/local/opt/python@3.9/libexec/bin/python /usr/bin/python

What Doesn't Work

# The changes to fish_user_paths don't get picked up
# by new invocations or subshells.
> exec fish -li
> which -a python
/usr/bin/python
/usr/local/opt/python@3.9/libexec/bin/python

> set -SL fish_user_paths $fish_user_paths: set in universal scope, unexported, with 1 elements $fish_user_paths[1]: |/usr/local/opt/python@3.9/libexec/bin|

> set -SL PATH $PATH: set in global scope, exported, a path variable with 5 elements $PATH[1]: |/usr/bin| $PATH[2]: |/bin| $PATH[3]: |/usr/sbin| $PATH[4]: |/sbin| $PATH[5]: |/usr/local/opt/python@3.9/libexec/bin/python|

Even trying to move the item doesn't seem to work.

> fish_add_path -Ppmg /usr/local/opt/python@3.9/libexec/bin/python > echo $status 1

Questions

These questions seem interrelated to me. I'm trying to discover:

  1. Where is fish getting PATH from when I haven't set it explicitly?
  2. Why can't I retain my PATH changes across shell instances?
  3. Why am I getting an error when trying to use fish_add_path to modify PATH directly?
CodeGnome
  • 2,131

1 Answers1

2

For the first question, it may depend on your distribution, but likely /etc/environment if your login goes through PAM. See this and this.

For the second part, not sure yet.

For the third, I'm fairly sure it's because you are pointing it to a file rather than a directory, right? The output of your which -a python says that /usr/local/opt/python@3.9/libexec/bin/python is the python executable, and yet that's the directory that you are trying to add. Just a simple copy/paste error, I'm guessing.

I believe that ...

fish_add_path -Ppmg /usr/local/opt/python@3.9/libexec/bin

or

fish_add_path --move --path /usr/local/opt/python@3.9/libexec/bin
# Since the prepend and global should be default

... should work.

Once that's in place, does it help with the second part of your question at all?

NotTheDr01ds
  • 28,025