如何在Mac OSX上将mongo命令添加到PATH

编程入门 行业动态 更新时间:2024-10-26 12:29:51
本文介绍了如何在Mac OSX上将mongo命令添加到PATH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用 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

本文发布于:2023-10-26 11:02:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1529943.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:上将   命令   如何在   Mac   PATH

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!