我正在osx上的emacs中运行bash,然后从另一个地方运行来自terminal.app的拉宝石 在bash中: which gem/usr/bin/gem 在终端: which gem/opt/local/bin/gem 如何更改bash以匹配终端? 我猜在emacs bash shell中$P
在bash中:
which gem /usr/bin/gem
在终端:
which gem /opt/local/bin/gem
如何更改bash以匹配终端?
我猜在emacs bash shell中$PATH是不同的.您可以通过在每个命令中运行此命令来检查它.echo $PATH
这是用于查找命令的查找路径.您需要在其中包含/ opt / local / bin.
export PATH="/opt/local/bin:$PATH"
将该行放在〜/ .bashrc文件中,当在emacs中使用时,它应该被bash拾取(除非它是在不同的用户或其他东西下运行).
更新:
正如Singletoned在评论中提到的那样,Emacs不会加载〜/ .bash_profile或〜/ .profile,但终端会加载.此文件可能已包含此PATH定义,导致两者具有不同的行为.
我建议将PATH定义从bash_profile文件移到bashrc中.但是,如果存在bash_profile,则终端不会加载bashrc.
解决方案是将此添加到〜/ .bash_profile.
if [ -f ~/.bashrc ]; then . ~/.bashrc fi
然后,您可以将其他所有内容移动到bashrc中,这将包含在bash_profile中.