安装 RVM 时,它返回一个警告:上述文件包含 PATH= 内部没有 $PATH,这可能会破坏 RVM

Posted

技术标签:

【中文标题】安装 RVM 时,它返回一个警告:上述文件包含 PATH= 内部没有 $PATH,这可能会破坏 RVM【英文标题】:While installing RVM, it is returning a WARNING: Above files contains PATH= with no $PATH inside, this can break RVM 【发布时间】:2021-12-17 00:21:17 【问题描述】:

问题说明

我正在为 Apple Silicon - Mac M1 运行 OS X,使用 .zshrc shell(不是 bash),并尝试按照以下说明安装 RVM 以贡献于开源项目:

    使用 Homebrew 安装 gpg 以验证 RVM 安装程序的完整性。 brew install gpg brew doctor 并得到了Your system is ready to brew.,看来我添加成功了。

    下载 RVM 安装程序的公钥。 gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB 而且我没有收到任何错误,似乎也成功了。

    要安装 RVM 和最新版本的 ruby​​ 和 rails,这可能是个好主意,请使用以下命令。 \curl -sSL https://get.rvm.io | bash -s stable --autolibs=enable 这将返回以下内容并带有 *Warning at the end

Downloading https://github.com/rvm/rvm/archive/1.29.12.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.12/1.29.12.tar.gz.asc
gpg: Signature made Fri Jan 15 23:46:22 2021 +05
gpg:                using RSA key 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
gpg: Good signature from "Piotr Kuczynski <piotr.kuczynski@gmail.com>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 7D2B AF1C F37B 13E2 069D  6956 105B D0E7 3949 9BDB
GPG verified '/Users/sarvarkhalimov/.rvm/archives/rvm-1.29.12.tgz'
Upgrading the RVM installation in /Users/sarvarkhalimov/.rvm/
    RVM PATH line found in /Users/sarvarkhalimov/.mkshrc /Users/sarvarkhalimov/.profile /Users/sarvarkhalimov/.bashrc /Users/sarvarkhalimov/.zshrc.
    RVM sourcing line found in /Users/sarvarkhalimov/.profile /Users/sarvarkhalimov/.bash_profile /Users/sarvarkhalimov/.zshrc /Users/sarvarkhalimov/.zlogin.
Upgrade of RVM in /Users/sarvarkhalimov/.rvm/ is complete.
/Users/sarvarkhalimov/.bash_profile:2:export PATH=/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
/Users/sarvarkhalimov/.bash_profile:5:export PATH=/opt/homebrew/bin:/opt/homebrew/bin:/Users/sarvarkhalimov/.rbenv/shims:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3/bin:/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3@global/bin:/Users/sarvarkhalimov/.rvm/rubies/ruby-2.7.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/sarvarkhalimov/.rvm/bin:/Users/sarvarkhalimov/.rvm/bin
/Users/sarvarkhalimov/.bash_profile:6:export PATH=/opt/homebrew/bin:/opt/homebrew/bin:/opt/homebrew/bin:/Users/sarvarkhalimov/.rbenv/shims:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3/bin:/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3@global/bin:/Users/sarvarkhalimov/.rvm/rubies/ruby-2.7.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/sarvarkhalimov/.rvm/bin:/Users/sarvarkhalimov/.rvm/bin
/Users/sarvarkhalimov/.bash_profile:7:export PATH=/opt/homebrew/bin:/opt/homebrew/bin:/opt/homebrew/bin:/opt/homebrew/bin:/Users/sarvarkhalimov/.rbenv/shims:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3/bin:/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3@global/bin:/Users/sarvarkhalimov/.rvm/rubies/ruby-2.7.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/sarvarkhalimov/.rvm/bin:/Users/sarvarkhalimov/.rvm/bin

  * WARNING: Above files contains PATH= with no $PATH inside, this can break RVM,
    for details check https://github.com/rvm/rvm/issues/1351#issuecomment-10939525
    to avoid this warning prepend $PATH


Thanks for installing RVM ????
Please consider donating to our open collective to help us maintain RVM.

????  Donate: https://opencollective.com/rvm/donate
    作为验证一切顺利的最后一步。 type rvm | head -1 这将返回rvm is a function。 但是,我收到rvm is a shell function from /Users/sarvarkhalimov/.rvm/scripts/cli

我的脚本(源)文件

1. ~/.bash_profile

source ~/.profile
export PATH=/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

export PATH=/opt/homebrew/bin:/opt/homebrew/bin:/Users/sarvarkhalimov/.rbenv/shims:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3/bin:/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3@global/bin:/Users/sarvarkhalimov/.rvm/rubies/ruby-2.7.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/sarvarkhalimov/.rvm/bin:/Users/sarvarkhalimov/.rvm/bin
export PATH=/opt/homebrew/bin:/opt/homebrew/bin:/opt/homebrew/bin:/Users/sarvarkhalimov/.rbenv/shims:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3/bin:/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3@global/bin:/Users/sarvarkhalimov/.rvm/rubies/ruby-2.7.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/sarvarkhalimov/.rvm/bin:/Users/sarvarkhalimov/.rvm/bin
export PATH=/opt/homebrew/bin:/opt/homebrew/bin:/opt/homebrew/bin:/opt/homebrew/bin:/Users/sarvarkhalimov/.rbenv/shims:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3/bin:/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3@global/bin:/Users/sarvarkhalimov/.rvm/rubies/ruby-2.7.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/sarvarkhalimov/.rvm/bin:/Users/sarvarkhalimov/.rvm/bin
export PATH="/usr/local/bin:$PATH"

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

2. ~/.bashrc

export PATH="$PATH:$HOME/.rvm/bin"

3. ~/.zshrc

eval "$(rbenv init -)"

export PATH="/opt/homebrew/bin:$PATH"
export PATH="/usr/local/bin:$PATH"

export PATH="$PATH:$HOME/.rvm/bin"

采取措施解决:

我在 2012 年遇到了 @elado 的以下 solution,我尝试将我的第一个导出路径 export PATH="$PATH:$HOME/.rvm/bin" 更改为 export PATH=$PATH:"$PATH:$HOME/.rvm/bin",但是当我运行 @ 时,我仍然得到相同的输出和相同的 *warning 987654338@.

那么,谁能建议我如何解决第 3 步和第 4 步中的问题(在我看来)?

最初由@SarvarKh 在https://github.com/rvm/rvm/issues/1351#issuecomment-956250296 中发布

编辑#1

*在将$PATH: 伪装成.bash_profile 后,第3 步的警告已解决。 更新.bash_profile文件:

source ~/.profile
export PATH=$PATH:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

export PATH=$PATH:/opt/homebrew/bin:/opt/homebrew/bin:/Users/sarvarkhalimov/.rbenv/shims:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3/bin:/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3@global/bin:/Users/sarvarkhalimov/.rvm/rubies/ruby-2.7.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/sarvarkhalimov/.rvm/bin:/Users/sarvarkhalimov/.rvm/bin

export PATH=$PATH:/opt/homebrew/bin:/opt/homebrew/bin:/opt/homebrew/bin:/Users/sarvarkhalimov/.rbenv/shims:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3/bin:/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3@global/bin:/Users/sarvarkhalimov/.rvm/rubies/ruby-2.7.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/sarvarkhalimov/.rvm/bin:/Users/sarvarkhalimov/.rvm/bin

export PATH=$PATH:/opt/homebrew/bin:/opt/homebrew/bin:/opt/homebrew/bin:/opt/homebrew/bin:/Users/sarvarkhalimov/.rbenv/shims:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3/bin:/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3@global/bin:/Users/sarvarkhalimov/.rvm/rubies/ruby-2.7.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/sarvarkhalimov/.rvm/bin:/Users/sarvarkhalimov/.rvm/bin

export PATH="/usr/local/bin:$PATH"

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

!然而

在运行type rvm | head -1 后我仍然得到rvm is a shell function from /Users/sarvarkhalimov/.rvm/scripts/cli 而不是得到rvm is a function

【问题讨论】:

希望这个问题能帮助许多愿意安装 RVM 的 macOS 用户,因为我遇到了这个问题并且暂时无法解决。我在 GitHub 的 RVM 存储库中创建了一个问题,但尚未收到回复。 我认为警告很清楚。由于前 4 个不包含 $PATH 您实际上只是一遍又一遍地覆盖 PATH 变量,而不是扩展它。例如export HELLO=1 &amp;&amp; export HELLO=2 &amp;&amp; echo $HELLO # 2 因为第二个导出覆盖了第一个但export HELLO=1 &amp;&amp; export HELLO=$HELLO:2 &amp;&amp; echo $HELLO # 1:2 因为第二个导出添加了系统变量$HELLO @engineersmnky 谢谢。我已经在第 3 步解决了该警告。但是,在运行type rvm | head -1 而不是获得rvm is a function 之后,我仍然得到rvm is a shell function from /Users/sarvarkhalimov/.rvm/scripts/cli。有什么想法吗? rvm is a shell function from ... 听起来不错。我不认为你应该有使用它的问题。但是,您应该真正清理bash_profile 中的PATH 定义。您现在将多次插入相同的路径到您的 PATH 变量中。从命令行尝试echo $PATH,你会看到。我建议从您的bash_profile 中删除重复项以进行清理。 @Casper 感谢您的回复。我将终端上的默认 shell 从 zsh 更改为运行 chsh -s /bin/bashbash。在那之后,我意识到我在过去的某个时间也安装了 rbenv,这导致了 $PATH 问题,我相信。因此,在卸载它并重新运行问题中提到的第 5 步后,我成功安装并在运行type rvm | head -1 后得到了rvm is a function。呼) 【参考方案1】:

问题由以下几部分组成:

1..bash_profile 中添加$PATH:。所以,我的.bash_profile 现在看起来像这样(也许可以清理,但不确定。如果你知道怎么做,请在 cmets 中告诉我或留下链接) .

    source ~/.profile
    export PATH=$PATH:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
    
    export PATH=$PATH:/opt/homebrew/bin:/opt/homebrew/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3/bin:/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3@global/bin:/Users/sarvarkhalimov/.rvm/rubies/ruby-2.7.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/sarvarkhalimov/.rvm/bin:/Users/sarvarkhalimov/.rvm/bin
    
    export PATH=$PATH:/opt/homebrew/bin:/opt/homebrew/bin:/opt/homebrew/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3/bin:/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3@global/bin:/Users/sarvarkhalimov/.rvm/rubies/ruby-2.7.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/sarvarkhalimov/.rvm/bin:/Users/sarvarkhalimov/.rvm/bin
    
    export PATH=$PATH:/opt/homebrew/bin:/opt/homebrew/bin:/opt/homebrew/bin:/opt/homebrew/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3/bin:/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3@global/bin:/Users/sarvarkhalimov/.rvm/rubies/ruby-2.7.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/sarvarkhalimov/.rvm/bin:/Users/sarvarkhalimov/.rvm/bin
    
    export PATH="/usr/local/bin:$PATH"
    
    [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
    export PATH="/opt/homebrew/bin:$PATH"

2. 我有rbenv,以前安装过,它是另一个 ruby​​ 版本管理器。所以,我不得不按照steps 卸载它。 *注意:删除带有rbenv的行时,请只删除与rbenv相关的部分,而不是整行。

例如,从以下位置删除/Users/sarvarkhalimov/.rbenv/shims:

export PATH=$PATH:/opt/homebrew/bin:/opt/homebrew/bin:/Users/sarvarkhalimov/.rbenv/shims:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3/bin:/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3@global/bin:/Users/sarvarkhalimov/.rvm/rubies/ruby-2.7.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/sarvarkhalimov/.rvm/bin:/Users/sarvarkhalimov/.rvm/bin

3. 我确实将我的默认 shell 终端从 zsh 更改为运行 chsh -s /bin/bashbash


RVM安装成功verification.

最后,当您按预期运行 type rvm | head -1 时,它会返回 rvm is a function

【讨论】:

这一定有帮助,如果没有,请发表评论。我会尽可能快地提供帮助和响应,我有点成为在 macOS 上安装 RVM 的大师)

以上是关于安装 RVM 时,它返回一个警告:上述文件包含 PATH= 内部没有 $PATH,这可能会破坏 RVM的主要内容,如果未能解决你的问题,请参考以下文章

警告! PATH 设置不正确,/Users/me/.rvm/gems/ruby-2.7.3/bin 不在首位

RVM 正在从我的 PATH 中删除 /usr/bin

Rvm 进行gem安装时必须输入密码Your user account isn't allowed to install to the system RubyGems 解决方案

RVM Ruby on Rails 安装

安装 Ruby 2.2.6 时 macOS Sierra 的 RVM 问题

安装RVM时现有宝石会发生什么?