How many ways can you set PATH in Catalina?

So I’ve noticed that my PATH contains a lot of old crud that no longer works in Catalina so I commented out most of it in ~/.bashrc which gets called from ~/.bash_profile (yeah, I’m not following Apple to zsh, at least not now). Anyway, regardless of what I seem to do PATH keeps retaining some of the old crud and for the life of me I can’t figure out where it’s coming from. I checked /etc/. login and bashrc both exist in there but they don’t contain any of what’s screwing up my PATH. Any ideas where else to look?

Have you checked your ~/.profile?

Thanks, @jcenters. I actually don’t have one. And /etc/profile looks fine.

Be sure to start a new Terminal window to make use of your changed .bash_profile, or else “source .bash_profile”.
Check with “echo $PATH”.
Oh, and look in your Terminal preferences for starting a new shell (“Shell opens with”).

All good advice, but I’m already doing that.

I’m in fact not using Terminal, but instead a regular old xterm through XQuartz.

I’ve been able to confirm my .bashrc is being picked up and changes I make there do show up in my PATH. But it’s the other stuff in there that I can’t seem to figure out.

Some of the old crud seems related to installing TeX ages ago (probably long before MacTeX). I just can’t figure where this pollution is coming from. I simply have no idea where that old junk is being picked up. :confused:

It might take heavy digging find out how and where, but the “cruft” in $PATH may well be added by a boot time procedure as, for example, an environment setup file for a no-longer-used application.

Thank you. That’s a great suggestion, @james.cutler. I was thinking about that too, but since the move to Catalina I have gotten rid of most of my old boot processes. Certainly, the only thing left right now related to TeX here is the pref panel “Tex Distribution” that allows selecting TeXLive versions. AFAIK it’s not connected to any boot processes. I’ve been through /Library/LaunchAgents and /Library/LaunchDaemons as well as their counterparts in ~/Library and cannot find anything suspicious there either. Am I missing any other hideouts?

Am I missing any other hideouts?

You could use Terminal.app to look at /etc – almost anything with “rc” in the name and, possibly, also .conf files. I suppose you could grep for “Tex”.

Even simpler, preference panels are automatically referenced by virtue of being installed. Try removing the pref panel “Tex Distribution” and restart. (Maybe logout and login is enough – it depends.)

[I tried replying through Discourse but failed. If there’s a duplicate, mea culpa.]

Have you tried looking into /usr/libexec/path_helper? (There’s a manpage for path_helper.) The keys are /etc/paths and /etc/paths.d/. Paths in the paths file are appended first, and then files in paths.d are read for paths to append. For bash, path_helper is executed from /etc/profile, so the various paths are set up before the user’s profile is executed.

A number of applications with shell-accessible executables insert path setup files into paths.d, such as XQuartz and Wireshark.

Maybe the TeX application created files in paths.d which are still causing trouble.

That’s exactly what I did when I initially tried figguring out where this stuff was coming from. I’m afraid no smoking gun in there.

I did that, but no change to PATH either I’m afraid.

Thanks for the good suggestions though. :slight_smile:

Bingo! :slight_smile:

That was it. There were some old leftovers in /etc/paths.d/ and clearing those out took care of it. Gotta remember to keep an eye on that directory in the future. Thank you! :slight_smile:

The one remaining question I have is why after all the stuff in path that comes from /etc/paths and /etc/paths.d/, I see my stuff from .bashrc appended twice. Essentially

/usr/local/bin:...lots:of:benign:stuff:...:mypath1:mypath2:mypath1:mypath2

when all I’ve been doing in .bashrc is something along the lines of

export PATH=$PATH:mypath1:mypath2

What I see is almost as if that export line were executed twice, but I have no idea why that would be happening. :confused: