6

我在 OS X (10.8.3) 上使用gem install watchr. 它安装在/usr/bin/watchr

$ which watchr
/usr/bin/watchr

但是,当我尝试调用它时$ watchr -v,系统找不到它。

$ watchr -v
-bash: /usr/local/bin/watchr: No such file or directory

我认为这与我的机器上路径的设置方式有关。我的问题:

  1. 修复它的正确方法是什么?
  2. 一般来说,什么程序应该去/usr/bin/vs. /usr/local/bin/
  3. 例如,当我这样做时$ /usr/bin/watchr -e 'watch(./hello.txt) ...',我们是在当前目录中还是在/usr/bin/中查看hello.txt ,即与watchr相同的目录?
4

3 回答 3

10

您的命令的路径被缓存了一个错误的值。尝试更新 bash 为路径存储的缓存目录。

hash -d watchr

我在这里找到了答案,其中 ctags 显示 /usr/local/bin/ctags,但是当我运行 ctags 时,它运行 /usr/bin/ctags。这怎么可能?

于 2013-05-05T15:31:18.613 回答
2

Is /usr/local/bin/watchr a broken symlink? That would make which watchr not include it but watchr would print this error:

-bash: /usr/local/bin/watchr: No such file or directory

I don't know why the gem that 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/.

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/*'.

Related questions about /usr/local/bin/ in general:

于 2013-04-29T04:55:18.890 回答
1

在您的主目录中创建一个名为 .profile 的文件并添加以下行。export PATH="/usr/local/bin:/usr/local/sbin:/usr/bin:$PATH"</p>

于 2014-01-19T00:47:28.427 回答