chapel-lang / chapel

a Productive Parallel Programming Language
https://chapel-lang.org
Other
1.77k stars 416 forks source link

setchplenv.fish corrupts PATH if run a second time #20405

Open mppf opened 2 years ago

mppf commented 2 years ago

I'm observing that running setchplenv.fish a second time corrupts $PATH. That is certainly not how it is supposed to work.

$ fish --version
fish, version 3.3.1

$ fish
Welcome to fish, the friendly interactive shell
mppf@zeus ~/w/12 ((c52abd37…))> echo $PATH
/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/games /usr/local/games /snap/bin /home/mppf/arcanist/bin/

mppf@zeus ~/w/12 ((c52abd37…))> source util/setchplenv.fish
Setting CHPL_HOME to /home/mppf/w/12
Updating PATH to include /home/mppf/w/12/bin/linux64-x86_64
                     and /home/mppf/w/12/util
Updating MANPATH to include /home/mppf/w/12/man

mppf@zeus ~/w/12 ((c52abd37…))> echo $PATH
/home/mppf/w/12/bin/linux64-x86_64 /home/mppf/w/12/util /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/games /usr/local/games /snap/bin /home/mppf/arcanist/bin/

mppf@zeus ~/w/12 ((c52abd37…))> source util/setchplenv.fish 
Setting CHPL_HOME to /home/mppf/w/12
Updating PATH to include /home/mppf/w/12/bin/linux64-x86_64
                     and /home/mppf/w/12/util
Updating MANPATH to include /home/mppf/w/12/man

mppf@zeus ~/w/12> echo $PATH
/home/mppf/w/12/bin/linux64-x86_64 /home/mppf/w/12/util . .

mppf@zeus ~/w/12> ls
Command 'ls' is available in the following places
 * /bin/ls
 * /usr/bin/ls
The command could not be located because '/usr/bin:/bin' is not included in the PATH environment variable.
ls: command not found
lucaferranti commented 2 months ago

I think the proper way to update the path is to use fish_add_path (see https://fishshell.com/docs/current/cmds/fish_add_path.html), directly using set does sound a bit fragile.