Macos – bash command on mac terminal not working anymore

.bash-profilebashmacosterminal

I have been trying to install blastn on my mac, but while doing messed up my bash command i guess (not a specialist…)

- using the nano command nano ~/.profile
- i`ve changed my PATH; export PATH=/Users/YourName/blast-2.2.22/bin:${PATH}
- now i can not run any command anymore in the terminal (also other shell)

-bash: export: `/Users/Tom/ncbi-blast-2.6.0+/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/ncbi/blast/bin': not a valid identifier

As i'm not a specialist, i'm stuck how to change things back…

Best Answer

Three steps: First, you probably can run commands from the terminal. You just somehow messed up your search path. But you can still start a program by specifying its full path.

E.g. /usr/local/bin/bash would still start bash, even if /usr/local/bin/ is not in your search path. (adjust the path as needed, I have no idea where OS X stores bash by default. I just used the location where bash is on FreeBSD).

So, yes, you can run commands. And you can use those commands to fix things.


Secondly, you might not need to look up all the paths. Setting a new path for your current shell should be as easy as typing export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" and pressing enter or return. This is only temporaily for the open shell, but it will make recovery much easier.


Thirdly, lets try to find the error and permanently fix it.

The error message is quite clear. Quoting your own post: export: /Users/Tom/ncbi-blast-2.6.0+/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/ncbi/blast/bin': not a valid identifier

Somewhere in your edits is an error. Open the .profile again either by temporarily restoring paths (see section 2) or by specifying the full path.

If you have a backupfile, restore that. If not look for entries like this:

PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/mysql/bin:$PATH or
`PATH="$PATH:/newfoldertosearch"

Locate your own edits. Remove them (or uncomment by placing a # in front of them and then try to locate the error. It can be as simple as having a ; instead of an :. Other easy to miss things are spaces or non-printable characters.

While editing this do not close your current shell. Keep the known working (or known temporarily restored one) open and test in a second shell. Which is good practice for any edits to your profile.



PS: The plus sign at the end of ncbi-blast-2.6.0+ in an unquoted string might be the case, but I got no OSX to test with.