繁体   English   中英

Homebrew和Ruby安装后持久的Mac终端语法错误

[英]Persistent Mac terminal syntax error after Homebrew and Ruby installation

https://gorails.com/setup/osx/10.10-yosemite上安装Homebrew和Ruby到Mac OS X 10.10.5的步骤包括在终端中运行这些行:

brew install rbenv ruby-build  

echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile source ~/.bash_profile

这两行现在都成功运行,但每次打开终端时都会出现此错误消息(名称替换为“x”):

-bash: /Users/x/.bash_profile: line 12: syntax error near unexpected token `then'
-bash: /Users/x/.bash_profile: line 12: `export PATH="/Users/x/anaconda/bin:$PATH"if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi'

搜索“终端打开时出现bash错误”的错误和变体并未找到删除错误消息的方法。

当您添加代码以将rbenv初始化为.bash_profile ,它会被错误地附加到该文件的最后一行,而不是添加到新行。

要解决此问题,请编辑文件〜/ .bash_profile(例如,通过运行nano ~/.bash_profile )并添加一个新行,以便该行的结尾如下所示:

export PATH="/Users/x/anaconda/bin:$PATH"
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi

然后,您可以使用Ctrl + x保存文件并退出编辑器。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM