Written by Robert Koch
TLDR: Look inside/etc/paths.d
for path entries that haven't been cleaned up.
Your PATH contains spaces, TABs, and/or newline (\n) characters.
Very annoying! This is probably going to lead me down a rabbit hole somewhere later but at the time I just wanted to get the project I was working on running. So I investigated what value(s) in my path were causing the error, I ran this useful command to split the path based on colons to easily parse it.
echo $PATH | tr ':' '\n'
This gave me the contents of my path variable in a more human readable format. After staring at it for a few minutes I saw the culprit...
/Applications/VMware Fusion.app/Contents/Public
.zshrc
file so I knew it wasn't in there, which
really did confuse me for a while. I spent a good hour looking through my path
entries and couldn't find anything. I even tried a general search in my $HOME
for PATH=
- no luck./etc
.
Having a look in there I found /etc/zprofile
and inside it this peculiar
code...if [ -x /usr/libexec/path_helper ]; theneval `/usr/libexec/path_helper -s`fi
path_helper
before, so I did a quick man lookup which
lead me to its description.The path_helper utility reads the contents of the files in the directories /etc/paths.d and /etc/manpaths.d and appends their contents to the PATH and MANPATH environment variables respectively.
ls
in /etc/paths.d
gave me
the answers that I was looking for.rw-r--r-- 224 root 2 Apr 02:46 10-cryptex.rw-r--r-- 23 root 13 Sep 2022 100-rvictl.r--r--r-- 47 root 30 Jan 2022 com.vmware.fusion.public.rw-r--r-- 20 root 5 Jul 2022 TeX.rw-r--r-- 43 root 10 Oct 2021 Wireshark
com.vmware.fusion.public
file.../Applications/VMware Fusion.app/Contents/Public
That's what we're looking for! So now all that's left to do is delete the file.
/etc/paths.d