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

7,044

Solution 1

I changed in the .bash_profile the

  • export PATH=$PATH:/bin

    to

  • export PATH="/usr/local/bin:$PATH"

and the system is back to normal.

Solution 2

The most likely cause is you have problems with exports in your .bashrc or .bash_profile eg, export PATH=PATH/bin which should be export PATH=$PATH:/bin.
In order to change this outside of the Terminal, you can use Command+Shift+. to toggle hidden files in finder to allow you to edit with TextEdit or another editor.

Share:
7,044

Related videos on Youtube

MyKMyk
Author by

MyKMyk

Updated on September 18, 2022

Comments

  • MyKMyk
    MyKMyk over 1 year

    History: I had installed Selenium (java_home was already taking care of and working). Now I was installing Android Studio(mac) and needed to adjust the env for Java_home. First I typed:

    • set Android_home
    • export Android_home=/Library/Android/Home
    • echo Android_home

    then:

    • nano .bash_profile

    Adding Android_home.

    • export Android_home=/Users/<username>/Library/Android/sdk
    • export PATH=$PATH:$Android_home/tools
    • export PATH=$PATH:$Android_home/tools/bin
    • export PATH=$PATH:$Android_home/platform-tools

    Lastly: $ source .bash_profile

    Then closed everything, reopened the terminal. The terminal instantly was running this one particular line (infinite-wise).

    -bash: export: 'PATH/bin': not a valid identifier

    error in terminal

    After a short while, it changes to

    --bash: export: 'PATH/bin': not a valid identifier

    --bash: /usr/libexec/java_home: Argument list too long

    Thank you for taking the time to read my question. [this is my first question ever. Apologies for newbee mistakes. ]

    .bash_profile [Opened text editor, pressed Command + Shift + > to show hidden files.]

    Export JAVA_HOME=$(/usr/libexec/java_home)
    PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
    export PATH
    
    export MONGO_PATH=/usr/local/mongodb
    export PATH=$PATH:$MONGO PATH/bin
    export Android_home=/Users/<username>/Library/Android/sdk
    export PATH=$PATH:$Android_home/tools
    export PATH=$PATH:$Android_home/tools/bin
    export PATH=$PATH:$Android_home/platform-tools
    source .bash_profile
    

    Update: To isolate the problem further I commented everything out in bash_profile except one, Java:

    • export PATH=$JAVA_HOME/bin:$PATH
    • export JAVA_HOME=/usr/libexec/java_home
    • export JAVA_HOME=/usr/libexec/java_home -v 1.8

    Now run echo $PATH Result: /Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home/bin:/ over and over gain

    another example: I commented everything out in bash_profile except one:

    • export PATH=$PATH:/bin

    save > close terminal > re-open > check the change with

    • echo $PATH

    all the terminal shows is this repetition/loop

    • /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/bin:/bin:/bin:/bin:/bin:/bin:/bin:/bin:....endless bin

    one more observation

    In the very beginning, when I open the terminal, something is running in the background which prevents me from typing something into the terminal. I need to press control + c to stop it. Couldn't find out what process this is.

    Is it possible that the .bash_profile or etc/paths is in conflict with .profile ?

    In.profileis only one PATH:

    (export PATH=~/.npm-global/bin:$PATH)

    • MyKMyk
      MyKMyk about 5 years
      Apologies about the confusion. I will leave the question on how to find the bash_profile file without the terminal as closed/answered and move on, opening a the follow up /underlying question: what causes the infinite loop.
    • MyKMyk
      MyKMyk about 5 years
      debug the startup file(s) is the core issue, indeed. Accepting your answer was my response since you helped solving a part of the issue. I didn't know that this was handled so narrow. This feels like conversations/comments on JIRA - One ticket, one issue. I will keep this in mind.
    • MyKMyk
      MyKMyk about 5 years
      I read chameleon link: I am new, I don't have a degree in computer science. I took a few classes (C++, Java): super bad vibes. There was this constant underlying theme in class who is smart, who knows more which was killing the atmosphere, the flow, just toxic. I am a humanist, my first foreign language was ancient Latin (for 7 years) - meaning in the literal meaning of intelligent I learned how detect an intellect with certain sensitivities versus a curious mind seeking answers. In regard to some comments there, I am a bit shocked. I think, I have an idea now where you are coming from. Thx
  • Kevin Rockwell
    Kevin Rockwell about 5 years
    Try looking at the files you changed in text-edit then if you can't change them from the terminal
  • MyKMyk
    MyKMyk about 5 years
    Terminal was indeed my first idea - but again I can't. Maybe I delete java first (without terminal), reinstall and hope that the uninstall was clean enough to allow me to reinstall without the past setup. I can use the text editor but I don't know where I can find the java folder without the finder (newbee in the mac universe). How would I find /usr/libexec/java_home or `PATH/bin' without the terminal?
  • Kevin Rockwell
    Kevin Rockwell about 5 years
    What files did you change in the Android download? And to go to the java folder you can use Shift-Command-G to go to files in finder, or the "go" menu and then the second to last entry.
  • Kevin Rockwell
    Kevin Rockwell about 5 years
    Open the profile in textedit by pressing Shift+Command+. (in Finder) in your home directory, then you should be able to open it in textedit
  • MyKMyk
    MyKMyk about 5 years
    @KamilMaciorowski done, ty!
  • MyKMyk
    MyKMyk about 5 years
    @KevinRockwell That is what I was looking for: pressing Shift+Command+. (in Finder) in your home directory, then you should be able to open it in textedit Thanks, Kevin!!!!
  • Kevin Rockwell
    Kevin Rockwell about 5 years
    @MyKMyk I'll incorporate it into the answer, my apologies for not understanding what you meant. You might also want to try wrapping the paths in quotes to help make things work better
  • MyKMyk
    MyKMyk about 5 years
    @KamilMaciorowski I see. It is my first post, my apologies. Thank you for your patience!
  • MyKMyk
    MyKMyk about 5 years
    @KevinRockwell as it says in the guidelines: if I am not clear about my question, I won't get a good answer. So apologies about not being clearer about the issue. Kevin, I re-wrote the issue which was only possible because you helped me to be more concise, more clear about what is relevant. Big thank you for helping me and your patience. I got the file open and from what I understand I didn't set the path right. Can you see which line in the bash profile file is giving me trouble?
  • MyKMyk
    MyKMyk about 5 years
    I changed in the .bash_profile the export PATH=$PATH:/bin to export PATH="/usr/local/bin:$PATH" and the system is back to normal.
  • MyKMyk
    MyKMyk about 5 years
    Thanks for pointing this out. First I didn't realize the impact of this line. So I uninstalled java, reinstalled it and started with the bash_profile from the beginning. When I googled the issue/ youtubed it, ect. didn't find a lot of answers. I ended up leaving out source .bash_profile. Terminal stopped running the lines. Again, thanks for explaining this. Do you recommend a good source to look up the whole environment variables spiel?
  • help-info.de
    help-info.de almost 3 years
    Welcome to Super User! Before answering an old question having an accepted answer (self answered here, look for green ✓) as well as other answers ensure your answer adds something new or is otherwise helpful in relation to them. Here is a guide on How to Answer. There is also tour for the site tour, and help center for the help center.