Mac打开Terminal报错-bash : : command not found

问题描述:  

Mac系统在打开Terminal的时候,报错-bash : : command not found。

问题分析:

报错并不影响Terminal的使用,于是忽略不计。但是在修改.bash_profile文件后,为了使配置生效,使用source命令,也是报错-bash : : command not found。

开始以为是source命令找不到,将/bin加入到环境变量中,还是报这个错误。

问题陷入困境。

在网上搜索,发现大部分问题都类似是 -bash:nginx: command not found,就是说两个::之间是有个命令的,是这个具体的命令找不到。而现在的报错没有看到这个命令,而是空格,说明把空格也当成了命令,这就说明.bash_profile中写了一个空格,被系统认为是命令来执行了。

打开.bash_profile,并没有看到空格,拷贝文件内容到文本编辑器中,也没有看到空格。

为了排查,打算注释掉所有命令,再一行一行放开命令,再执行source命令,看具体是哪行报错。发现工作量太大。

无意中使用VS Code打开.bash_profile,就发现了异常,如下:

去掉这个特殊字符,再次source,不再报错。

可见,系统将这个特殊字符当成命令来执行了,而找不到这个命令,且这个命令显示在终端中是一个空格,所以导致上述报错。

总结:

1、问题要举一反三,看别人出现的问题和自己的问题差别在哪里,类比问题所在。

2、注意特殊字符,尽量使用富文本编辑器,例如VS Code。

原文地址:https://www.cnblogs.com/leanfish/p/10274745.html

时间: 2024-07-28 18:04:00

Mac打开Terminal报错-bash : : command not found的相关文章

Mac 执行 gulp 报错 -bash: gulp: command not found

在mac系统下安装gulp,之后执行gulp 报如下错误: -bash: gulp: command not found 回溯安装过程发现问题如下 1.执行 npm root: Applications/XAMPP/xamppfiles/htdocs/gulp/node_modules 以上路径说明npm只安装到了本地目录,需要执行如下命令更改npm目录: npm config set prefix /usr/local 再执行:npm root  结果:usr/local/lib/node_m

mac下python3.6安装mysqlclient报错mysql_config: command

用mac在python3.6的环境下学习django,按照官网的步骤,却无法安装mysqlclient.报错mysql_config: command not found. 命令如下: $ pip3 install mysqlclient pip3是因为有两个python版本,给python3.6对应的pip起了个别名.不然提示找不到.报错如下: Collecting mysqlclient Using cached mysqlclient-1.3.12.tar.gz Complete outp

安装MySQL-python报错error: command 'gcc' failed with exit status 1

[[email protected] MySQL-python-1.2.3]# python setup.py install function) .... _mysql.c:133: error: 'ER_SYNTAX_ERROR' undeclared (first use in this function) _mysql.c:380: error: '_mysql_ConnectionObject' has no member named 'connection' _mysql.c:382

nagios报错NRPE: Command 'check_heartbeat' not defined

最近在做heartbeat监控的时候,在nagios服务器端报警提示:NRPE: Command 'check_heartbeat' not defined 但是在nagios客户端/usr/local/nagios/libexec/check_nrpe -H 192.168.3.211 -c check_heartbeat都能够正常执行,查了很多资料主要有以下几种情况: 1.nagios客户端nrpe.cfg配置文件命令写错 2.nagios客户端libexec下没有此命令 我的都不是上述两种

MyEclipse打开 HTML 报错Failed to create the part's controls

拷贝代码时有时会弹出这个错误,页面仍然可以访问,但是无法编辑很郁闷. MyEclipse默认打开编辑页面是MyEclipse visual html designer 右击html页面选择open with,点击 MyEclipse html Editer即可. MyEclipse打开 HTML 报错Failed to create the part's controls

[Android]打开eclipse报错:发现了以元素 'd:skin' 开头的无效内容。此处不应含有子元素。

[错误] 打开eclipse报错:发现了以元素 'd:skin' 开头的无效内容.此处不应含有子元素. [具体报错信息] Error parsing D:\android-sdks\system-images\android-22\android-wear\armeabi-v7a\devices.xml cvc-complex-type.2.4.d: 发现了以元素 'd:skin' 开头的无效内容.此处不应含有子元素. Error: Error parsing D:\android-sdks\s

转:Loadrunner打开https报错“Internet…

Loadrunner 录制htpps 协议通过IE打开页面,报错“Internet Explorer cannot display the webpage”. 但是直接打开IE不通过 loadrunner打开https页面却可以正常打开. 问题解决如下(Windows 7): 执行:cmd 然后执行命令:certutil -setreg chain\minRSAPubKeyBitLength 512 重启电脑,问题解决. 参考文章: http://eyeontesting.com/questio

开着idea,死机了,关机重启。重启之后,重新打开idea报错java.lang.AssertionError:upexpected content storage modification

开着idea,死机了,关机重启.重启之后,重新打开idea报错java.lang.AssertionError:upexpected content storage modification. goole得到: If you cannot even open your project in IntelliJ: Close IntelliJ Go to the directory <your_home>/.IntelliJIdeaXX/system/cache where XX is your

shell脚本在cygwin下运行报错: $&#39;\r&#39;: command not found

在cygwin 下运行shell脚本,出现"$'\r': command not found",这是win dos与Unix文本编辑方式不同造成的.可以使用cygwin工具dos2unix将script改为unix格式. $ dos2unix test.sh dos2unix: converting file test.sh to UNIX format ... $ sh test.sh 如此便可解决. 参见:http://lxs647.iteye.com/blog/2084375 s