I’m trying to add some directories to my PATH environment variable but it doesn’t seem to be working. This seems to be the main error:
xsel -o -b
Can't add to PATH environment variable
Here is what I have tried:
❯ source .zshenv
...
setopt verbose
exec > >(tee "$DIR"/logfile)
exec 2>&1
...
function pathadd() {
if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
PATH="${PATH:+"$PATH:"}$1"
fi
}
...
pathadd "$HOME"/.local/bin # for python packages installed with the '--user' option
pathadd "/root/.local/bin" # for python packages installed globally
...
xsel -o -b
Can't add to PATH environment variable
\00\00\00...
qe(Be[me[38;2;84;88;98me[48;2;30;34;42m ...
❯ sudo pipx install watch-xfce-xfconf
sudo pipx install watch-xfce-xfconf
creating virtual environment...
installing watch-xfce-xfconf...
⚠️ Note: '/root/.local/bin' is not on your PATH environment variable. These
apps will not be globally accessible until your PATH is updated. Run `pipx
ensurepath` to automatically add it, or manually modify your PATH in your
shell's config file (i.e. ~/.bashrc).
done! ✨ 🌟 ✨
installed package watch-xfce-xfconf 1.0.4, installed using Python 3.11.5
These apps are now globally available
- watch-xfce-xfconf
❯ echo $PATH
echo $PATH
/home/user/.local/bin:/sbin:/bin:/usr/bin:/usr/local/bin:/usr/local/sbin:/usr/bin/site\_perl:/usr/bin/vendor\_perl:/usr/bin/core\_perl:/home/user/.cargo/bin
As you can see, I’m trying to add some custom directories to PATH by modifying .zshenv
and running source, but it doesn’t seem to be working. When I install a new package with pipx, it warns me that /root/.local/bin
is not in PATH. And echo $PATH
confirms that my custom additions are not there.
Any ideas what I’m doing wrong or how to properly modify PATH? Thanks!
As a possible solution, I’ve thought about logging the PATH variable at different places in the zsh configuration files to see if that helps. Let me know if you have any other suggestions for things I could try to get the PATH variable to persist correctly.