Sudoers Secure Path
I ran into a weird problem on my work computer. I installed python via macports but
sudo which python results in
system python (
/usr/bin/python) instead of the macports python (
which python shows
me the macports installed one. What’s going on?
Turns out when you use sudo there is a feature called secure path. If set, it will always override your local path.
/etc/sudoers and sure enough, my workplace sets the secure path. Furthermore any attempts to remove it get
overwritten every time configs are resynced.
Some potential solutions:
- Symlink the binaries you want to use into one of the paths that are in secure path.
- Just call explicit binary locations.