简体   繁体   English

RVM / rbenv / 终端 $PATH 错误:(eval):18: `PATH=/usr/local/opt/...' 附近的解析错误

[英]RVM / rbenv / terminal $PATH error: (eval):18: parse error near `PATH=/usr/local/opt/...'

I noticed the following error in my Mac (Monterey version 12.4) terminal upon opening it today:今天打开我的 Mac(Monterey 版本 12.4)终端时,我注意到以下错误:

(eval):18: parse error near `PATH=/usr/local/opt/...'

I suspected that it was related to my installation and removal of Ruby Version Manager (RVM - https://rvm.io/ ) last week.我怀疑这与我上周安装和删除 Ruby 版本管理器(RVM - https://rvm.io/ )有关。 When I tried using RVM to install Ruby 2.6.1, the installation failed, and upon doing some research, it looked like RVM has issues with install older versions of Ruby on Macs.当我尝试使用 RVM 安装 Ruby 2.6.1 时,安装失败,在进行一些研究后,看起来 RVM 在 Mac 上安装旧版本的 Ruby 时存在问题。 Therefore, I removed RVM and installed rbenv instead, which worked.因此,我删除了 RVM 并安装了 rbenv,这很有效。 Anyway, to uninstall RVM, I ran:无论如何,要卸载 RVM,我运行了:

rvm implode

I also removed an RVM line from my bash_profile.我还从我的 bash_profile 中删除了 RVM 行。 This was all done last week.这一切都是上周完成的。

Upon seeing this new error in my terminal, I ran echo $PATH , which output this:在我的终端中看到这个新错误后,我运行echo $PATH ,它输出以下内容:

/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/francoortega/.rvm/bin

I'm guessing that the .rvm part of this $PATH may be part of the problem.我猜这个 $PATH 的 .rvm 部分可能是问题的一部分。

Next I ran open ~/.bash_profile and open ~/.bashrc , which had this info:接下来我运行open ~/.bash_profileopen ~/.bashrc ,其中包含以下信息:

bash_profile bash_profile

[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*eval "$(rbenv init -)"

bashrc .bashrc

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"

I tried deleting the rvm info from these files, but that didn't have any effect, so I undid those deletions.我尝试从这些文件中删除 rvm 信息,但这没有任何效果,所以我撤消了这些删除。 Also, it seemed odd that the bash_profile had a line that include rvm and rbenv info此外,bash_profile 有一行包含rvmrbenv信息似乎很奇怪

Then, I ran open ~/.zshrc , which output this:然后,我运行open ~/.zshrc ,输出如下:

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"

eval "$(rbenv init - zsh)"export PATH="/usr/local/opt/ruby/bin:/usr/local/lib/ruby/gems/2.6.10/bin:$PATH"

I tried deleting the .rvm line, but that had no effect, so I undid that deletion.我尝试删除 .rvm 行,但没有效果,所以我取消了删除。 Then, surprisingly, when I deleted the rbenv file, this removed the terminal error.然后,令人惊讶的是,当我删除 rbenv 文件时,这消除了终端错误。

  1. However, I don't want to delete rbenv, so I'm not sure what would be the proper way to fix this error.但是,我不想删除 rbenv,所以我不确定修复此错误的正确方法是什么。

  2. Additionally, I wasn't able to find the path listed in the error ( /usr/local/opt/ ) either.此外,我也找不到错误( /usr/local/opt/ )中列出的路径。

  3. And since I no longer have RVM, should I delete the rvm lines from the bash_profile bashrc, and .zshrc files?既然我不再有 RVM,我应该从 bash_profile bashrc 和 .zshrc 文件中删除 rvm 行吗?

It looks like the following steps solved my issue:看起来以下步骤解决了我的问题:

  1. Removed this line from .zshrc:从 .zshrc 中删除了这一行:
eval "$(rbenv init - zsh)"export PATH="/usr/local/opt/ruby/bin:/usr/local/lib/ruby/gems/2.6.10/bin:$PATH"
  1. Removed this line from .bash_profile:从 .bash_profile 中删除了这一行:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*eval "$(rbenv init -)"
  1. Removed these two lines from .bashrc and .zshrc:从 .bashrc 和 .zshrc 中删除了这两行:
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"

My .bashrc and .zshrc files are now empty, and my .bash_profile only contains:我的 .bashrc 和 .zshrc 文件现在是空的,我的 .bash_profile 只包含:

[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile

My terminal now open without any error message.我的终端现在打开,没有任何错误消息。

Also, I found it strange that the line in my .bash_profile mentioned both rvm and rbenv (see original post above), but reading the rbenv docs, it turns out that I was supposed to remove rvm before installing rbenv, so maybe having rvm on my machine when I install rbenv is what led to this mashup.此外,我发现我的 .bash_profile 中的行同时提到了rvmrbenv (参见上面的原始帖子),但阅读 rbenv 文档,结果发现我应该在安装 rbenv 之前删除 rvm,所以可能打开了 rvm我安装 rbenv 时的机器是导致这个混搭的原因。

Finally, as I mentioned in my original post, I had already removed rvm, but today I removed rbenv with the following two commands (it had been installed via Homebrew):最后,正如我在原帖中提到的,我已经删除了 rvm,但是今天我使用以下两个命令删除了 rbenv(它是通过 Homebrew 安装的):

rm -rf `rbenv root`
brew uninstall rbenv

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

相关问题 关于鱼中eval $ PATH的错误消息 - Error Message on eval $PATH in Fish svn从默认路径/ usr / bin而不是/ opt / local / bin使用 - svn use from default path /usr/bin instead of /opt/local/bin dyld:库未加载:/usr/local/opt/icu4c/lib/libicui18n.62.dylib 在 Mac 上使用 brew 安装节点后运行 php 时出错 - dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib error running php after installing node with brew on Mac 路径,/usr/bin/ 和 /usr/local/bin/ - Path, /usr/bin/ and /usr/local/bin/ 自制pyenv安装错误dyld:库未加载:/usr/local/opt/readline/lib/libreadline.7.dylib - Homebrew pyenv install error dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib 在MacOSX上安装EMBOSS期间发生错误“ dyld:库未加载:/usr/local/opt/jpeg/lib/libjpeg.8.dylib” - error during installation of EMBOSS on MacOSX “dyld: Library not loaded: /usr/local/opt/jpeg/lib/libjpeg.8.dylib” 错误:无法从 /usr/local/opt/pygtk/.brew/pygtk.rb 获取运行时依赖项 - Error: could not get runtime dependencies from /usr/local/opt/pygtk/.brew/pygtk.rb .zshrc:3:当我在 Mac 上打开终端时,“>”附近的解析错误 - .zshrc:3: parse error near `>' when i open terminal on mac 采购RVM时为什么会出现PATH错误? - Why do I get a PATH error when sourcing RVM? 每次打开终端时,$ PATH错误 - $PATH error every time Terminal is Opened
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM