Ubuntu
PATH 在手動獲取之前不會從 ~/.profile 導出
我正在嘗試在 ~/.profile 中修改我的 PATH:
export PATH=$PATH:/opt/jdk1.8/bin echo "Path is exported."
我將始終通過 SSH 登錄,這就是為什麼我將它放在 ~/.profile 中。我使用 zsh (oh-my-zsh) 作為我的預設 shell,在我的 ~/.zprofile 中我正在採購 ~/.profile:
source ~/.profile
奇怪的是,當我通過 SSH 登錄時,我看到“路徑已導出”。消息,這意味著源語句 .zprofile 正在工作,但是當我回顯我的 $PATH 時,’/opt/jdk1.8/bin’ 失去了。如果我隨後手動獲取〜/ .profile,則路徑會正確更新,因此我不確定為什麼在登錄時獲取路徑時它沒有正確導出路徑。如果有幫助的話,這一切都在一個流浪者的盒子裡。有任何想法嗎?
編輯: zsh -ixc exit 2>&1 | 的輸出 grep 路徑:
+/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'
我弄清楚了問題所在。基於@L。Levrel 的評論,我在 .zshrc 中添加了一個 echo 語句,因為他說 ssh 登錄 shell 既是互動式的又是登錄的。果然,.zshrc 是在 .zprofile 之後獲取的,並且路徑在 .zshrc 中被覆蓋。將 Java 變數的導出命令移動到 ~/.zshrc 解決了這個問題。