我有以下env
文件,它会在shell启动时运行:
PATH=/Users/paulcowan/bin:$PATH
PATH=$PATH:~/bin
PATH=$PATH:$HOME/.local/bin:$PATH
PATH=$PATH:/usr/local/bin:/usr/bin:/bin
PATH=$PATH:"$RBENV_ROOT/bin:$PATH"
export PATH
但是当我运行echo $PATH
我明白了:
/Users/paulcowan/.nvm/versions/node/v5.0.0/bin:/usr/local/rbenv/shims:PATH:/Users/paulcowan/.local/bin:/Users/paulcowan/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/MacGPG2/bin:/usr/local/rbenv/shims:PATH:/Users/paulcowan/.local/bin:/Users/paulcowan/bin:/Users/paulcowan/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/rbenv/bin:PATH:/Users/paulcowan/.local/bin:/Users/paulcowan/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/MacGPG2/bin:/usr/local/rbenv/shims:PATH:/Users/paulcowan/.local/bin:/Users/paulcowan/bin:/Users/paulcowan/bin:/usr/local/bin:/usr/bin:/bin
重复相同的值。
如何正确配置路径?
答案 0 :(得分:2)
你在几行的开头和结尾重复了$ PATH:
PATH=$PATH:$HOME/.local/bin:$PATH
PATH=$PATH:"$RBENV_ROOT/bin:$PATH"
为什么不这样设置呢?
export PATH=/Users/paulcowan/bin:~/bin:$HOME/.local/bin:/usr/local/bin:/usr/bin:/bin:$RBENV_ROOT/bin:$PATH
答案 1 :(得分:0)
如果我很清楚你的脚本试图做什么,那么正确的代码可能是:
PATH=/Users/paulcowan/bin:$PATH
PATH=~/bin:$PATH
PATH=$HOME/.local/bin:$PATH
PATH=$PATH:/usr/local/bin
PATH=/usr/bin:$PATH
PATH=/bin:$PATH
PATH=$PATH:$RBENV_ROOT/bin
export PATH