$PATH is not updated

12,433

Solution 1

PATH is constructed first from /etc/paths, then from the files in /etc/paths.d, and then from .bash_profile. Starting from the last step, methodically remove each step, and test to see if your problem is recreated.

  1. Comment out every line in .bash_profile and save (or you could delete/rename it).
  2. Close out your terminal and restart it to reconstruct your PATH.
  3. echo $PATH. It should contain everything from /etc/paths.

If everything from /etc/paths is included, then your problem lies in your .bash_profile. Uncomment one line at a time until you recreate your problem. Then you will know which line is your problem, and will be able to troubleshoot that instead of a vague PATH issue.

Alternatively, if deleting .bash_profile has no effect, then you have a problem that's occurring before .bash_profile acts. Check the files in /etc/paths.d - those also get appended to your PATH. Move them out of paths.d and then test whether your PATH is properly constructed from /etc/paths.

It seems like a lot of people have some trouble with rvm, as in this post and this post , so I'm guessing the problem lies in your .bash_profile. Good luck and let us know.

Solution 2

Do this in the shell:

$ source ~/.bashrc

This makes the current session aware of the change.

Share:
12,433

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin over 1 year

    It seems all about this was already discussed, but I can't resolve my problem. I have all necessary strings in /etc/paths

    /usr/bin
    /bin
    /usr/sbin
    /sbin
    /usr/local/bin
    

    in ~/.bash_profile

    export PATH=$PATH:/usr/local/mysql/bin
    export PATH=$PATH:$HOME/.rvm/bin
    export PATH="$(brew --prefix php54)/bin:$PATH"
    export PATH="$(brew --prefix)/bin:$PATH"
    

    But every time I execute

    echo $PATH
    

    in terminal, I get only

    /usr/local/bin
    

    if I put .bash_profile strings to .profile or .bashrc I have no effect.

    • Admin
      Admin over 10 years
      Have you quit terminal and retry?
    • Admin
      Admin over 10 years
      yes, sure, I restarted it!
    • Admin
      Admin over 10 years
      Type ". .bash_profile" to reload .bash_profile and update any functions you add.
    • Admin
      Admin over 10 years
      it didn't help, I don't understand why there are no paths from /etc/paths? only /usr/local/bin
    • naren
      naren over 10 years
      Any change if you put those lines in .bashrc instead?
    • Admin
      Admin over 10 years
      Hm, I moved to .bashrcand make empty bash_profile and it helped. But I believe I've made this already(:
    • naren
      naren over 10 years
      From man bash When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order,
    • Penghe Geng
      Penghe Geng over 10 years
      You sure there's no such line somewhere in your .bash_profile or .bashrc: export PATH=/usr/local/bin?
  • Admin
    Admin over 10 years
    I still have no effect! I even have no /usr/bin in PATH.