Mac opens Terminal and reports an error -bash:: command not found

Problem Description:  

When opening Terminal on Mac system, an error -bash:: command not found was reported.

problem analysis:

The error does not affect the use of Terminal, so it is ignored. But after modifying the .bash_profile file, in order to make the configuration effective, using the source command also reported an error -bash:: command not found.

At first I thought it was because the source command could not be found, and I added /bin to the environment variable, but still reported this error.

The problem is in trouble.

Searching on the Internet, I found that most of the problems are similar to -bash:nginx: command not found, that is to say, there is a command between the two ::, but the specific command cannot be found. But the current error report did not see this command, but a space, which means that the space is also regarded as a command, which means that a space is written in .bash_profile, which is considered as a command to be executed by the system.

Open .bash_profile, and no spaces are seen. Copy the contents of the file to a text editor, and no spaces are seen.

In order to troubleshoot, I plan to comment out all the commands, let go of the commands line by line, and then execute the source command to see which line is reporting the error. Found that the workload is too large.

I accidentally opened .bash_profile with VS Code, and found an exception, as follows:

Remove this special character, source again, and no more errors will be reported.

It can be seen that the system executes this special character as a command, but cannot find this command, and this command is displayed as a space in the terminal, which leads to the above error.

Read More:

Leave a Reply

Your email address will not be published. Required fields are marked *