bash 路径,/usr/bin/ 和 /usr/local/bin/
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16270480/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Path, /usr/bin/ and /usr/local/bin/
提问by moey
I installed watchron OS X (10.8.3) using gem install watchr. And it's installed in /usr/bin/watchr
我安装watchr在OS X(10.8.3)使用gem install watchr。它安装在/usr/bin/watchr
$ which watchr
/usr/bin/watchr
However, when I tried to call it $ watchr -v, the system couldn't find it.
但是,当我尝试调用它时$ watchr -v,系统找不到它。
$ watchr -v
-bash: /usr/local/bin/watchr: No such file or directory
I think this is related to how the path is set up on my machine. My questions:
我认为这与如何在我的机器上设置路径有关。我的问题:
- What is the right way to fix it?
- In general, what programs should go to
/usr/bin/vs./usr/local/bin/? - When I do e.g.
$ /usr/bin/watchr -e 'watch(./hello.txt) ...', are we looking at the hello.txtin the current directory or in /usr/bin/i.e. the same directory as watchr?
- 修复它的正确方法是什么?
- 一般来说,哪些程序应该去
/usr/bin/vs./usr/local/bin/? - 当我执行 eg 时
$ /usr/bin/watchr -e 'watch(./hello.txt) ...',我们是在当前目录中查看hello.txt还是在/usr/bin/ 中,即与watchr相同的目录?
回答by Alex Mooney
The path to your command was cached with a bad value. Try to update the cached directory that bash has stored for the path.
您的命令的路径被缓存为错误值。尝试更新 bash 为路径存储的缓存目录。
hash -d watchr
I found the answer over here which ctags shows /usr/local/bin/ctags but when I run ctags it runs /usr/bin/ctags. How is this possible?
我在这里找到了ctags 显示 /usr/local/bin/ctags的答案,但是当我运行 ctags 时,它会运行 /usr/bin/ctags。这怎么可能?
回答by Lri
Is /usr/local/bin/watchr a broken symlink? That would make which watchrnot include it but watchrwould print this error:
/usr/local/bin/watchr 是一个损坏的符号链接吗?这将使which watchr不包括它但watchr会打印此错误:
-bash: /usr/local/bin/watchr: No such file or directory
I don't know why the gemthat comes with OS X installs programs in /usr/bin/, but generally /usr/bin/ is meant for preinstalled programs, and package managers use something like /opt/local/bin/ or /usr/local/bin/.
我不知道为什么gemOS X 附带的程序会在 /usr/bin/ 中安装程序,但通常 /usr/bin/ 用于预装程序,并且包管理器使用 /opt/local/bin/ 或 /usr 之类的东西/本地/斌/。
I also have /usr/local/bin/ before other folders on the path, and I put most programs that I install or compile manually to /usr/local/bin/. I used to have a separate ~/bin/ folder, but it's easy to find non-Homebrew programs with something like find /usr/local/bin ! -lname '../Cellar/*'.
我在路径上的其他文件夹之前也有 /usr/local/bin/,并且我将大多数我手动安装或编译的程序放在 /usr/local/bin/ 中。我曾经有一个单独的 ~/bin/ 文件夹,但很容易找到类似find /usr/local/bin ! -lname '../Cellar/*'.
Related questions about /usr/local/bin/ in general:
一般有关 /usr/local/bin/ 的相关问题:
回答by John Barraco
create a file called .profile in your home directory and add the following line. export PATH=“/usr/local/bin:/usr/local/sbin:/usr/bin:$PATH”
在您的主目录中创建一个名为 .profile 的文件并添加以下行。导出路径=“/usr/local/bin:/usr/local/sbin:/usr/bin:$PATH”

