Messed up $PATH variable in Mac OS X
8,605
If you messed up your ~/.bash_profile
you can always edit it by supplying the absolute path to the editor:
/usr/bin/nano ~/.bash_profile
Remove any changes to PATH
and press CtrlO, then ↩. Overwrite the file and reload your shell. Your path settings should be restored.
Other files that set your PATH
on OS X are:
~/.bash_login
(if~/.bash_profile
doesn't exist)~/.profile
(if~/.bash_login
doesn't exist)/etc/profile
- Everything in
/etc/paths.d/
- Finally, for GUI apps:
~/.MacOSX/environment.plist
Always remember to use the correct formatting for your new PATH
, depending on whether you want your custom binaries to take precedence over system binaries:
export PATH=/some/other/path:$PATH
… or the other way 'round:
export PATH=$PATH:/some/other/path
Related videos on Youtube
Author by
sudesh
Updated on September 18, 2022Comments
-
sudesh over 1 year
I did something to my PATH.
I was trying to add some new path and now none of the command like
open ~/.bash_profile
work, andecho $PATH
only shows one path which is/Application/Filename
.Is there a way to fix this? This is my Mac OS X Lion.
-
HikeMike over 11 yearsAlternatively, open
.bash_profile
in any GUI text editor, e.g. TextEdit, by pressingCmd-Shift-.
in the Open… dialog to display hidden files and folders. -
sudesh over 11 yearsone fore question though, i do the export PATH.... on the terminal, and every time i reload the terminal the path is not set. how do i make it the permanent path ?
-
sudesh over 11 yearsnever mind i answered my own question. i used /usr/bin/nano ~/.bash_profile and wrote the path there, saved it and restarted the terminal, now everything is working fine.