How to remove entry from $PATH on mac
Solution 1
What you're doing is valid for the current session (limited to the terminal that you're working in). You need to persist those changes. Consider adding commands in steps 1-3 above to your ${HOME}/.bashrc
.
Solution 2
echo $PATH
and copy it's valueexport PATH=""
export PATH="/path/you/want/to/keep"
Solution 3
Check the following files:
/etc/bashrc
/etc/profile
~/.bashrc
~/.bash_profile
~/.profile
~/.MacOSX/environment.plist
Some of these files may not exist, but they're the most likely ones to contain $PATH
definitions.
Solution 4
On MAC OS X Leopard and higher
cd /etc/paths.d
There may be a text file in the above directory that contains the path you are trying to remove.
vim textfile //check and see what is in it when you are done looking type :q
//:q just quits, no saves
If its the one you want to remove do this
rm textfile //remove it, delete it
Here is a link to a site that has more info on it, even though it illustrates 'adding' the path. However, you may gain some insight.
Solution 5
If you're removing the path for Python 3 specifically, I found it in ~/.zprofile
and ~/.zshrc.
Related videos on Youtube
Comments
-
Tushar Koul about 3 years
I was trying to install Sencha Touch SDK tools 2.0.0 but could not run it properly. It created an entry in the $PATH variable. Later I deleted the sencha sdk tools folder but didn't realize that the path variable is still there.
When i did
echo $PATH
I got -/Applications/SenchaSDKTools-2.0.0-beta3:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
I searched on how to remove variables from $PATH and followed these steps :
- Gave the command
PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
- Did
echo $PATH
which showed/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
- gave the command
export PATH
- Closed terminal and reopened it. Gave the command
echo $PATH
. This time I got/Applications/SenchaSDKTools-2.0.0-beta3:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
Can anyone tell me what am i doing wrong?
- Gave the command
-
Tushar Koul about 11 yearsi'm sorry, i didn't quite get what you are saying. Where should I add the ${HOME}\.bashhrc command?
-
Tushar Koul about 11 yearsand I was aware of the commands being valid for the current terminal session. Thats why i thought "export" would work
-
devnull about 11 yearsAdd the commands in steps 1 & 3 to the file
${HOME}/.bashrc
(at the end of the file). Open a new terminal and executeecho $PATH
. -
devnull about 11 yearsSimply
export VARIABLE=VALUE
wouldn't persistVARIABLE
for all sessions. You need to say that in a startup file, e.g.${HOME}/.bashrc
or/etc/profile
(if the changes are intended for all users on the system). -
Tushar Koul about 11 yearsI opened the file using
nano ~\.bashrc
..it already hadexport PATH=/Applications/SenchaSDKTools-2.0.0-beta3:$PATH
there. Also, when i try to edit and save I'm getting Permission denied. -
Tushar Koul about 11 years~/.profile returned "no such file" and all others returned "permission denied"
-
Ansgar Wiechers about 11 yearsYou need superuser permissions for editing files in
/etc
. You should be able to at least read all of the files, though (provided they do exist). What are the permissions on the files? (ls -el filename
) -
Tushar Koul about 11 yearswhats the difference between bashrc in the /etc directory and the bashrc in the ~/ directory?
-
Tushar Koul about 11 yearsadding in bash_profile helped me remove it from PATH variable. I opened it using
sudo nano ~/.bash_profile
-
Ansgar Wiechers about 11 yearsThe one in
/etc
affects all users, the one on your home directory (~
) only your own user. And the settings in~/.bashrc
take precedence over the ones in/etc/bashrc
. -
Mike Furlender over 8 yearsIn the future I advise you to read the body of the question before answering.
-
schalkneethling almost 8 yearsAlso note that after running
export PATH=""
you might see errors such as: -bash: tail: No such file or directory -bash: sed: No such file or directory That is expected. -
Crocode over 7 yearsTo me changing in
~/.profile
worked. I'm using MACOS X El Capitan
. I think by default, it's taking from~/.profile
-
zapstar over 5 yearsAlso remember to look inside
/etc/paths.d/
-
Noumenon over 3 yearsOther options:
~/.zshrc
and~/.zprofile
. -
ObiHill about 3 years@AnsgarWiechers You should also add
/etc/paths
file and/etc/paths.d
directory to the list. -
Brod about 3 yearsThis was exactly what I needed to find the culprit. /etc/paths.d/ had the bad entry. Thanks @BannerMan
-
analyst_47 almost 3 yearsQuite direct!! Thank you
-
Kirit Vaghela over 2 yearsfor me it's
${HOME}/.zshrc
file -
Pawan over 2 years
export PATH=""
is throwing error aszsh: bad assignment