警告! PATH 没有设置好,/Users/me/.rvm/gems/ruby-2.7.3/bin 不是最开始的地方

Warning! PATH is not properly set up, /Users/me/.rvm/gems/ruby-2.7.3/bin is not at first place

描述

当我 运行 rvm -v.

时,我仍然收到下面给出的警告
Warning! PATH is not properly set up, /Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3/bin is not at first place.
         Usually this is caused by shell initialization files. Search for PATH=... entries.
         You can also re-add RVM to your profile by running: rvm get stable --auto-dotfiles
         To fix it temporarily in this shell session run: rvm use ruby-2.7.3
         To ignore this error add rvm_silence_path_mismatch_check_flag=1 to your ~/.rvmrc file.
rvm 1.29.12-next (master) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]

虽然在我看来 type rvm | head -1 返回 rvm is a function 后 RVM 安装成功。

重现步骤

我正在使用 OS X for Apple Silicon - Mac M1,默认 bash shell。 所以,我安装了默认 Ruby 并安装了 Git,用自制软件重新安装它们。

.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:/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"

export PATH="/opt/homebrew/bin:$PATH"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

.zshrc 如果需要的话。

eval "$(rbenv init -)"

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="/opt/homebrew/bin:$PATH"
export PATH="/usr/local/bin:$PATH"

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.

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

.bashrc

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

并尝试按照下面列出的步骤安装 RVM:

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

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

  3. 要安装 RVM 和最新版本的 ruby 和 rails,这可能是个好主意,请使用以下命令。 \curl -sSL https://get.rvm.io | bash -s stable --autolibs=enable 返回以下内容(似乎没问题):

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/.zlogin.
Upgrade of RVM in /Users/sarvarkhalimov/.rvm/ is complete.

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

  Donate: https://opencollective.com/rvm/donate
  1. 作为验证一切是否顺利的最后一步。 type rvm | head -1 正在返回 rvm is a function。 这确认安装已成功按照 rvm.oi documentation

预期行为

当我 运行 rvm -v 时,至少,我期望不会有显示在顶部 描述部分 的警告,这也下面简要给出:

Warning! PATH is not properly set up, /Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3/bin is not at first place.

实际行为

我想我已将其包含在上面的 重现步骤 部分中。

调试模式:

我已经尝试了issue or Whosebug中给出的解决方案,但我仍然无法解决$PATH warning

环境信息

运行 rvm info returns:

Warning! PATH is not properly set up, /Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3/bin is not at first place.
         Usually this is caused by shell initialization files. Search for PATH=... entries.
         You can also re-add RVM to your profile by running: rvm get stable --auto-dotfiles
         To fix it temporarily in this shell session run: rvm use ruby-2.7.3
         To ignore this error add rvm_silence_path_mismatch_check_flag=1 to your ~/.rvmrc file.

ruby-2.7.3:
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

  system:
    uname:        "Darwin Sarvars-MacBook-Air.local 20.6.0 Darwin Kernel Version 20.6.0: Tue Oct 12 18:33:38 PDT 2021; root:xnu-7195.141.8~1/RELEASE_ARM64_T8101 arm64"
    name:         "OSX"
    version:      "11.6"
    architecture: "arm64"
    bash:         "/bin/bash => GNU bash, version 3.2.57(1)-release (arm64-apple-darwin20)"
    zsh:          "/bin/zsh => zsh 5.8 (x86_64-apple-darwin20.0)"
    remote_path:  "osx/11.6/arm64"
    xcode:        ""

  rvm:
    version:      "1.29.12 (latest)"
    updated:      "13 minutes 4 seconds ago"
    path:         "/Users/sarvarkhalimov/.rvm"
    autolibs:     "[enable] Allow RVM to use package manager if found, install missing dependencies, install package manager (only OS X)."

  ruby:
    interpreter:  "ruby"
    version:      "2.7.3p183"
    date:         "2021-04-05"
    platform:     "arm64-darwin20"
    patchlevel:   "2021-04-05 revision 6847ee089d"
    full_version: "ruby 2.7.3p183 (2021-04-05 revision 6847ee089d) [arm64-darwin20]"

  homes:
    gem:          "/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3"
    ruby:         "/Users/sarvarkhalimov/.rvm/rubies/ruby-2.7.3"

  binaries:
    ruby:         "/Users/sarvarkhalimov/.rvm/rubies/ruby-2.7.3/bin/ruby"
    irb:          "/Users/sarvarkhalimov/.rvm/rubies/ruby-2.7.3/bin/irb"
    gem:          "/Users/sarvarkhalimov/.rvm/rubies/ruby-2.7.3/bin/gem"
    rake:         "/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3/bin/rake"

  environment:
    PATH:         "/opt/homebrew/bin:/usr/local/bin:/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:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/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:/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:/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"
    GEM_HOME:     "/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3"
    GEM_PATH:     "/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3:/Users/sarvarkhalimov/.rvm/gems/ruby-2.7.3@global"
    MY_RUBY_HOME: "/Users/sarvarkhalimov/.rvm/rubies/ruby-2.7.3"
    IRBRC:        "/Users/sarvarkhalimov/.rvm/rubies/ruby-2.7.3/.irbrc"
    RUBYOPT:      ""
    gemset:       ""

提前致谢! 我也在 rvm 仓库上创建了一个 issue

解决方案

我找到了解决方案 here,其中说明如下:

I encountered a similar error using Mac OS 10.14.6 and RVM 1.29.9.

For me the issue was resolved by moving the following code in my .bash_profile to the bottom of the file:

# RVM can encounter errors if it's not the last thing in .bash_profile
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to path for scripting (to manage Ruby versions)
export PATH="$GEM_HOME/bin:$PATH"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"  # Load RVM into a shell session *as a function*