我正在使用 university.mongodb/(顺便说一句,很棒的材料),但是我无法将mongo命令添加到我的路径中.
I'm using MongoDb 2.6.1 following the material from university.mongodb/ (great material by the way) but I am not being able to add to my path the mongo commands.
我已遵循本指南 docs .mongodb/manual/tutorial/install-mongodb-on-os-x/,我这样修改了.bashrc
I've followed this guide docs.mongodb/manual/tutorial/install-mongodb-on-os-x/ and I modified my .bashrc like this
export PATH=/Users/jonathancaballero/bin/mongodb/mongodb_2.6.1/bin:$PATH确实存在二进制文件的位置(直接使用查找程序检查)
And there is indeed where the binaries are (checked using the finder directly)
所以我的问题是为什么我不能从终端的任何位置使用mongod?
推荐答案请将PATH导出文件放入.bash_profile:
export PATH=/path/to/your/mongo/bin:$PATH将其放入.bash_profile的原因是,当bash作为登录外壳程序启动时,通常会执行该文件,而对于交互式非登录外壳程序,通常会摘除.bashrc.通常发生的情况是.bashrc来自.bash_profile.这里似乎并非如此.在MacOS X上,当您启动终端时,不会执行.bashrc.上帝知道为什么,因为打开的外壳应该是交互式非登录外壳,因此应该执行.bashrc.
The reason to put it into .bash_profile is that this file will usually get executed when bash is started as a login shell while .bashrc usually is exectuted for interactive non-login-shells. What usually happens is that .bashrc gets sourced in .bash_profile. This does not seem to be the case here. On MacOS X when you start a Terminal, .bashrc does not get executed. God knows why, as the shell opened should be an interactive non-login shell and therefor should execute .bashrc.
另一种,尽管更具侵入性"的解决方案是将以下内容添加到.bash_profile.
Another, albeit more "intrusive" solution would be to add the following to .bash_profile.
if [ -f ~/.bashrc ]; then source ~/.bashrc fi对于那些对细节感兴趣的人:看一下 bash的联机帮助页
For those who are interested in the details: take a look into the according sections of bash's manpage
更多推荐
如何在Mac OSX上将mongo命令添加到PATH
发布评论