Unable to access /usr/local/bin

Discussion in 'Mac Basics and Help' started by viajero205, Jul 29, 2015.

  1. viajero205 macrumors newbie

    Joined:
    Jul 29, 2015
    Location:
    San Francisco
    #1
    Hi,

    I'm using a Macbook Pro, OS 10.9.5.

    On Terminal, when I run echo $PATH, I see the following which indicates that /usr/local/bin is indeed in my path:

    echo $PATH
    /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

    However, if I try to cd to it, I get:

    cd /usr/local/bin
    -bash: cd: /usr/local/bin: Not a directory

    Additionally, I don't seem to have a bash_profile. Any suggestions on how to troubleshoot these issues?

    Thanks!
     
  2. MacUser2525 macrumors 68000

    MacUser2525

    Joined:
    Mar 17, 2007
    Location:
    Canada
    #2
    In a Terminal opened by going to /Applications/Utilities/Terminal.app.

    Code:
    sudo mkdir /usr/local/bin
    
    Then
    Code:
    nano ~/.bash_profile
    
    My bash profile stripped of the parts not applicable to you.

    Code:
    MacUser2525:~$ cat .bash_profile
    # ~/.bash_profile: executed by bash(1) for login shells.
    # see /usr/share/doc/bash/examples/startup-files for examples.
    # the files are located in the bash-doc package.
    
    # the default umask is set in /etc/login.defs
    #umask 022
    
    # include .bashrc if it exists
    if [ -f ~/.bashrc ]; then
      . ~/.bashrc
    fi
    
    # set PATH so it includes user's private bin if it exists
    if [ -d ~/Bin ] ; then
      PATH=~/Bin:"${PATH}"
    fi
    
    To write the file and exit nano hit the ctrl and x keys at the same time answer y to saving the file logout and back it for the profile to be loaded or in the terminal.

    Code:
    source ~/.bash_profile
    
    To load it without the logout/in or now I think on it quit terminal and reopen for it to work in the new login shell..
     
  3. DeltaMac macrumors 604

    DeltaMac

    Joined:
    Jul 30, 2003
    Location:
    Delaware
    #3
    I have the same $PATH, but when I look in the /usr/local folder, no bin folder exists.
    I don't think it is a default folder, even if the $PATH suggests that it exists, perhaps you simply need to make a bin folder in the proper location.
    That being a Unix path, I guess you would need to make that in a Unix way, which I don't have a need to know how to do that.
    Now I see that MacUser2525 has a much better answer - with a proper method to make the folder. I would have been fumbling around to do that.
     
  4. viajero205 thread starter macrumors newbie

    Joined:
    Jul 29, 2015
    Location:
    San Francisco
    #4
    Thanks, MacUser2525, I'll make the changes you suggest, but I have a question. Why does /usr/local/bin appear in my path if it's not actually there?
    Thanks, again!
     
  5. viajero205 thread starter macrumors newbie

    Joined:
    Jul 29, 2015
    Location:
    San Francisco
    #5
    Thanks!
     
  6. viajero205 thread starter macrumors newbie

    Joined:
    Jul 29, 2015
    Location:
    San Francisco
    #6
    Unfortunately, MacUser2525, none of these steps seem to have worked. I still don't seem to have a profile and when I try to access /usr/local/bin, I still get:
    cd /usr/local/bin
    -bash: cd: /usr/local/bin: Not a directory
     
  7. MacUser2525, Jul 29, 2015
    Last edited: Jul 29, 2015

    MacUser2525 macrumors 68000

    MacUser2525

    Joined:
    Mar 17, 2007
    Location:
    Canada
    #7
    Well using the sudo to create the directory should have no choice but to work you are root user using the command and can do anything including destroy the system with the wrong command. The same with creating the file if you create and save it it will be there. What were the steps you took with the commands I listed? And what are you trying to do here anyways? If trying to install some software by compiling it then when you do the make install step it will create the directory needed if it does not exist when installing it. At least it should if not then the programmer has no concept of proper installation and I for one would not trust any software with clueless developer.

    Edit could be the entire tree is missing for the directory to create it all in one go.

    Code:
    sudo mkdir -p /usr/local/bin
    
    Now this tells the mkdir command to create as root the /usr/local/bin directory with the -p telling it that if the /usr is missing create the parent directory same with if the /usr/local is not there now that has no choice but to happen. If it does not your system is beyond saving as it is totally FUBAR. You need new install where it is not messed up by not allowing the simple creation of a directory.
     
  8. DeltaMac macrumors 604

    DeltaMac

    Joined:
    Jul 30, 2003
    Location:
    Delaware
    #8
    If you tried the sudo mkdir command, which creates the folder that you want, then it should be there.
    If you look in your /usr/local folder, is there actually a bin folder there?

    Do you NEED a profile?
    I don't think you will find a bash_profile, unless you need to do something different from the login defaults.

    MacUser2525 has the best question, I think. What exactly are you trying to do?
     
  9. MacUser2525, Jul 29, 2015
    Last edited: Jul 29, 2015

    MacUser2525 macrumors 68000

    MacUser2525

    Joined:
    Mar 17, 2007
    Location:
    Canada
    #9
    Missed this one. You can have anything in the PATH it is an environment variable. The directories listed in it do not have to exist but make no sense to be there if not present on the system. Now whatever you are doing which is telling you to edit the .bash_profile so you can presumable add to the PATH is wanting to use that variable to allow execution of its program.

    Edit: If you look at my example profile you will see it adds a users Bin directory to the start of the PATH. This PATH variable is searched in the order listed for programs so that if I have two programs with the same name the one in my Bin directory will be the one loaded. In that case if I wanted the second different one used I need to use what is called the absolute path like /usr/local/bin/second_exactly_named_program_not_in_user_Bin.
     
  10. hiddenmarkov macrumors 6502a

    Joined:
    Mar 12, 2014
    Location:
    Japan
    #10

    some cli apps will need you to create a . based profile for some features if not there.

    Not sure what OP is doing but I have had to create to type some things to make pyenv happy when I want to run different versions of python. Pyenv is a cli app aviallable via homebrew recipe that basically lets you run python in whatever version you want in the shell its called up in. After you download the versions ofc..done in app as well.
     

Share This Page