【问题标题】:Bash error when opening terminal [closed]打开终端时出现 Bash 错误[关闭]
【发布时间】:2015-09-06 16:40:08
【问题描述】:

我最近使用以下命令在我的 Mac 上安装了 Ruby:

brew install rbenv ruby-build

然后我被指示输入此命令以将 rbenv 添加到 bash,以便在每次打开终端时加载:

# Add rbenv to bash so that it loads every time you open a terminal
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
source ~/.bash_profile

现在,每次我打开终端都会出现这个错误:

Last login: Sun Sep  6 17:30:09 on ttys000
-bash: /Users/pw/.bash_profile: line 1: syntax error near unexpected token `source'
-bash: /Users/pw/.bash_profile: line 1: `if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi source /Users/pw/.bash_profile'

关于如何阻止此错误显示的任何想法?

谢谢

【问题讨论】:

  • source ~/.bash_profile 行不应出现在您的~/.bash_profile 中。使用 TextEdit 打开它并删除该行。
  • 如果失败,请点击您的问题下方的edit 并粘贴您的~/.bash_profile 的全部内容
  • source ~/.bash_profile的部分。您似乎已在 .bash_profile 文件中将两行方向合并为一行。

标签: bash terminal


【解决方案1】:

~/.bash_profile 底部应该有一行:

if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi

就是这样。没有提到source anything

【讨论】:

    猜你喜欢
    • 2021-11-27
    • 2019-06-27
    • 1970-01-01
    • 2014-04-15
    • 2013-05-15
    • 2017-02-07
    • 1970-01-01
    • 2016-04-03
    相关资源
    最近更新 更多