I am trying to modify my PATH in ~/.profile:

export PATH=$PATH:/opt/jdk1.8/bin
echo "Path is exported."

I will always login via SSH so that's why I have it in ~/.profile. I am using zsh (oh-my-zsh) as my default shell and in my ~/.zprofile I am sourcing ~/.profile:

source ~/.profile

The weird part is that when I login over SSH, I see the "Path is exported." message which means that the source statement .zprofile is working but when I echo my $PATH the '/opt/jdk1.8/bin' is missing. If I then manually source ~/.profile, the path is updated properly so I am not sure why it doesn't export the path properly when it gets sourced on login. This is all inside a vagrant box if that helps. Any ideas?

Edit: Output of zsh -ixc exit 2>&1 | grep PATH:

+/home/vagrant/.zcompdump:1254> _postpatcomps=( '(p[bgpn]m*|*top[bgpn]m)' _pbm '(texi(2*|ndex))' _texi '(tiff*|*2tiff|pal2rgb)' _tiff '-value-,(ftp|http(|s))_proxy,-default-' _urls '-value-,LC_*,-default-' _locales '-value-,*path,-default-'
_directories '-value-,*PATH,-default-' _dir_list '-value-,RUBY(LIB|OPT|PATH),-default-' _ruby '*/X11(|R<4->)/*'
_x_arguments 'yodl(|2*)' _yodl )
+/home/vagrant/.zshrc:56> export 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games'
+/home/vagrant/.zcompdump-vagrant-ubuntu-trusty-64-5.0.2:1256> _postpatcomps=( '(p[bgpn]m*|*top[bgpn]m)' _pbm '(texi(2*|ndex))' _texi '(tiff*|*2tiff|pal2rgb)' _tiff '-value-,(ftp|http(|s))_proxy,-default-' _urls '-value-,LC_*,-default-' _locales '-value-,*path,-default-'
_directories '-value-,*PATH,-default-' _dir_list '-value-,RUBY(LIB|OPT|PATH),-default-' _ruby '*/X11(|R<4->)/*'
_x_arguments 'yodl(|2*)' _yodl )
+nvm:409> PATH=+nvm:409> nvm_strip_path /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games /bin
+nvm:409> PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
+nvm:411> PATH=+nvm:411> nvm_prepend_path /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games /home/vagrant/.nvm/versions/node/v5.0.0/bin
+nvm:411> PATH=/home/vagrant/.nvm/versions/node/v5.0.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
+nvm:417> MANPATH=+nvm:417> nvm_strip_path /home/vagrant/.nvm/versions/node/v5.0.0/share/man:/usr/local/man:/usr/local/share/man:/usr/share/man:/opt/jdk1.8/man /share/man
+nvm:417> MANPATH=/usr/local/man:/usr/local/share/man:/usr/share/man:/opt/jdk1.8/man
+nvm:419> MANPATH=+nvm:419> nvm_prepend_path /usr/local/man:/usr/local/share/man:/usr/share/man:/opt/jdk1.8/man /home/vagrant/.nvm/versions/node/v5.0.0/share/man
+nvm:419> MANPATH=/home/vagrant/.nvm/versions/node/v5.0.0/share/man:/usr/local/man:/usr/local/share/man:/usr/share/man:/opt/jdk1.8/man
+nvm:420> export MANPATH
+nvm:422> export PATH
+nvm:424> export 'NVM_PATH=/home/vagrant/.nvm/versions/node/v5.0.0/lib/node'
  • 1
    Something is doubtless trampling on PATH. What does zsh -ixc exit 2>&1 | grep PATH show going on?
    – thrig
    Apr 6, 2016 at 15:51
  • Are you sourcing something else after ~/.profile in ~/.zprofile?
    – kos
    Apr 6, 2016 at 16:04
  • @thrig I added the output of that command in my question. @kos Thats the only line in my ~/.zprofile. In my ~/.profile, after I export my modified path, I am sourcing ~/.nvm/nvm.sh, which might have something to do with it. I am going to try moving the path exporting to the bottom.
    – Sam
    Apr 6, 2016 at 16:10
  • I moved the export to the bottom of ~/.profile and still no luck.
    – Sam
    Apr 6, 2016 at 16:12
  • What happens when you disable that nvm stuff? (Also, in hindsight, grep -i path= should catch both string PATH and array path assignments.)
    – thrig
    Apr 6, 2016 at 16:20

1 Answer 1


I figured out what the problem was. Based on @L. Levrel's comment, I added an echo statement to the .zshrc, since he said that ssh login shells are both interactive and login. And sure enough, the .zshrc gets sourced AFTER the .zprofile, and the path is being overwritten in .zshrc. Moving the export command for the Java variable to ~/.zshrc solved the problem.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .