Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Path, /usr/bin/ and /usr/local/bin/

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?
like image 245
moey Avatar asked Apr 29 '13 02:04

moey


People also ask

Should I use usr bin or usr local bin?

-- /usr/bin This is the primary directory for executable programs. Most programs executed by normal users which are not needed for booting or for repairing the system and which are not installed locally should be -- /usr/local/bin Binaries for programs local to the site.

What's the difference between bin and usr bin?

/bin contains executable files that are part of the core operating system. These files need to be accessible before /usr gets mounted. (for instance, the mount command is in /bin/mount ). /usr/bin contains executable files that are not part of the core operating system.

What is the difference between usr and usr local?

In distributions like Ubuntu, /usr is where packages are supposed to install stuff and /usr/local is where the system administrator can install stuff outside the packaging system. From the Filesystem Hierarchy Standard: The /usr/local hierarchy is for use by the system administrator when installing software locally.

What is usr local bin in Mac?

It's an abbreviation of “user related” and contains various read-only data, libraries, documentation, binaries, and other read-only software — all the things that apps on your Mac need to operate smoothly, but that users don't really ever need to see.


3 Answers

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?

like image 101
Alex Mooney Avatar answered Oct 11 '22 22:10

Alex Mooney


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:

  • https://unix.stackexchange.com/questions/8656/usr-bin-vs-usr-local-bin-on-linux
  • https://unix.stackexchange.com/questions/4186/what-is-usr-local-bin-came-across-it-in-an-script-installation-for-applescript
like image 27
Lri Avatar answered Oct 11 '22 22:10

Lri


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”
like image 43
John Barraco Avatar answered Oct 11 '22 22:10

John Barraco