当 运行 任何 rails 命令时找不到 'activesupport'

Could not find 'activesupport' when running any rails cmnd

我正在尝试在我的 MacOS 上设置 Rails,每当尝试 运行 任何命令(例如 rails -vrails new app 时 运行 都会遇到此错误, 或 bundle exec rails server。我使用

设置 rails

gem install rails -v 6.1.3.2

`Could not find 'activesupport' (= 6.1.4.1) among 90 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/Users/sam/.rvm/gems/ruby-2.6.5:/Users/sam/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0' at: /Users/sam/.rvm/gems/ruby-2.6.5/specifications/railties-6.1.4.1.gemspec, execute `gem env` for more information`

.zshrc 文件有这个:

export ANDROID_SDK=/Users/sam/Library/Android/sdk
export PATH=/Users/sam/Library/Android/sdk/platform-tools:$PATH
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi

.bash_profile

export ANDROID_HOME=/Users/sam/Library/Android/sdk
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH


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

export PATH="$HOME/.rbenv/bin:$PATH"
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
eval "$(rbenv init -)"
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
eval "$(rbenv init -)"

可能有多个版本的 Rails 安装程序,因为您尝试使用 rbenv 安装程序并且错误路径指向由 rvm 安装的 rails。尝试 运行 以下操作:

  • \curl -sSL https://get.rvm.io | bash -s stable --rails
  • cd进入你的项目目录,bundle i
  • 确保 ruby gem 与您安装的版本匹配,ruby --version