6

I installed watchr on OS X (10.8.3) using gem install watchr. And it's installed in /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
-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:

  1. What is the right way to fix it?
  2. In general, what programs should go to /usr/bin/ vs. /usr/local/bin/?
  3. When I do e.g. $ /usr/bin/watchr -e 'watch(./hello.txt) ...', are we looking at the hello.txt in the current directory or in /usr/bin/ i.e. the same directory as watchr?
moey
  • 10,587
  • 25
  • 68
  • 112

3 Answers3

11

The path to your command was cached with a bad value. Try to update the cached directory that bash has stored for the path.

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?

Community
  • 1
  • 1
Alex Mooney
  • 733
  • 1
  • 8
  • 16
  • Thanks, man. I just ran into this when setting up Erlang and Elixir. Their official repository messed up in Ubuntu / Linux Mint. Your comment saved me from a possibly long bug-hunt and may do so in the future too. ;) I can't believe I didn't know that one before. (Any more keywords for future googlers I should add to my answer?) – bid May 19 '17 at 16:07
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:

Community
  • 1
  • 1
Lri
  • 26,768
  • 8
  • 84
  • 82
  • I saw several symlinks in _/usr/local/bin/_ but didn't find a symlink for _watchr_. Were you saying that _/usr/bin/_ is more for the system install; whereas _/usr/local/bin/_ is for a manual install i.e. programs that were installed manually by a user manually? – moey Apr 29 '13 at 09:37
  • After experimenting more on this, here's what I learned. As explained above {{/usr/local/bin/}} is used often by package manager e.g. _brew_ installs {{/usr/local/Cellar/*}}. For manual install, it's really up to the user where to place the bits. – moey Jul 28 '13 at 03:06
1

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”
Volker E.
  • 5,911
  • 11
  • 47
  • 64
John Barraco
  • 390
  • 1
  • 6