bash not finding program

Discussion in 'Mac Programming' started by dancks, Nov 20, 2013.

  1. dancks macrumors member

    dancks

    Joined:
    Nov 8, 2009
    #1
    I know that in order to find to program either the proper path or the path needs to be a part of the $PATH variable.

    I'm trying to set up homebrew. its in /usr/local/bin because it refuses to run in /usr/bin for some reason. Thing is unless I specify /usr/local/bin/brew it will give me:

    -bash: /usr/bin/brew: No such file or directory

    Why does this happen?

    Does the fact that I set it up (and then removed from) /usr/bin make a difference? why? if it doesn't look through every specified path in $PATH, then what is $PATH for?
     
  2. ratsg macrumors 6502

    Joined:
    Dec 6, 2010
    #2
    So is /usr/local/bin in your path?

    This seems pretty obvious, am I missing something here?
     
  3. dancks thread starter macrumors member

    dancks

    Joined:
    Nov 8, 2009
    #3
    Yes it is. Thats why I was confused.
     
  4. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #4
    Please post the exact command you gave that elicited the message:
    Code:
    -bash: /usr/bin/brew: No such file or directory
    
    Also post the exact value of PATH at the time you gave the command.


    If there used to be a command 'brew' located in /usr/bin, and you removed it, but haven't started a new shell, then bash probably thinks that /usr/bin/brew still exists, because bash hashes the directories listed in PATH. That is, bash scans the directories in PATH, builds an internal hashtable, then looks up command-names in the hashtable expecting to quickly discover which directory to run the command from.

    See here:
    https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/bash.1.html
    then find the word hash on that page.

    You can tell bash to rehash the directories in PATH (see hash under SHELL BUILTIN COMMANDS at the above link).


    Enter this command, and post the complete output (if any):
    Code:
    type -P brew ; type -a brew
    
     
  5. dancks thread starter macrumors member

    dancks

    Joined:
    Nov 8, 2009
    #5
    Code:
    me:~me$ brew
    is what caused the output in question.

    the other stuff:

    Code:
    me:~me$ type -P brew; type -a brew
    /usr/local/bin/brew
    brew is /usr/local/bin/brew
    
    Code:
    me:~me$ echo $PATH
    /opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/sw/bin:/sw/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin:/usr/texbin:/usr/X11/bin
    me:~me$ 
    
    You were right about the shell hash thing. Thanks. Now if I could only find a way to update X11 library on 10.6 I'll be golden.
     

Share This Page