1

If it matters my setup is Zshell with Prezto on OSX. I have a Heroku path which I don't need. Years ago I remember going through a Heroku tutorial. I am unsure where it is specified. I'd also like to know if those rvm paths should be at the top. Some of the output from echo $PATH comes from my .zhsrc file. I am unsure where other parts of it originate.

echo "${PATH//:/'\n'}"
/usr/local/heroku/bin'
'/Users/joe/.rvm/gems/ruby-2.2.0/bin'
'/Users/joe/.rvm/gems/ruby-2.2.0@global/bin'
'/Users/joe/.rvm/rubies/ruby-2.2.0/bin'
'/usr/local/bin'
'/usr/bin'
'/bin'
'/usr/sbin'
'/sbin'
'~/.composer/vendor/bin'
'/opt/X11/bin'
'/usr/local/MacGPG2/bin'
'/usr/local/bin'
'/usr/local/sbin'
'/usr/local/bin/node'
'/Users/joe/Library/wpcs/vendor/squizlabs/php_codesniffer/scripts'
'~/.composer/vendor/bin'
'/Users/joe/.rvm/bin

$ cat /etc/paths returns:

/usr/bin
/bin
/usr/sbin
/sbin
~/.composer/vendor/bin
JAstuccio
  • 1,502
  • 2
  • 18
  • 20
  • Set and export a `PS4` that prints both the name of the file being executed and the line number, and run `PATH=/usr/local/bin:/usr/bin:/bin zsh -l -i -x` to run an interactive login shell that's printing that `PS4` before each command (and then that command, as-expanded) to stderr. Capture that stderr to a file, search the file for the entries you don't want/expect, and there you are. – Charles Duffy Sep 02 '16 at 20:19
  • Thank you Charles, but what you are suggesting is beyond my understanding. I learned PS4 has to do with debugging. This command gives me some output `PS4=; set -x; PATH=/usr/local/bin:/usr/bin:/bin zsh -l -i -x` I am not capturing stderr to a file. I did find the rvm and heroku paths coming from `.zlogin` – JAstuccio Sep 06 '16 at 12:32
  • You need to actually put a value into PS4 specifying what you want it to log. Setting it to an empty string is useless. That said, while I could specify a good PS4 value for bash offhand, zsh is out of my wheelhouse. (Used to use it a bit over a decade ago, vowed never again after I saw how sloppy my scripting was getting when targeting POSIX shells). – Charles Duffy Sep 06 '16 at 13:43

1 Answers1

1

There are lots of places to look for. I'd recommend these:

grep PATH etc/zshenv
grep PATH ~/.zshenv   
grep PATH etc/zprofile 
grep PATH ~/.zprofile   
grep PATH etc/zshrc    
grep PATH ~/.zshrc      
grep PATH etc/zlogin   
grep PATH ~/.zlogin
Mateusz Piotrowski
  • 8,029
  • 10
  • 53
  • 79
Nelson Marcos
  • 477
  • 2
  • 16
  • 2
    Since the OP is using tools such as rvm, there are *definitely* scripts being included/sourced from those dotfiles which are modifying PATH themselves -- meaning that one needs to check not just these files, but everything they source/include. Easier to log actual execution, and thus be assured of getting everything. – Charles Duffy Sep 02 '16 at 20:20