运行任何 rails cmnd 时找不到“activesupport”
Posted
技术标签:
【中文标题】运行任何 rails cmnd 时找不到“activesupport”【英文标题】:Could not find 'activesupport' when running any rails cmnd 【发布时间】:2021-11-02 05:32:13 【问题描述】:我正在尝试在我的 MacOS 上设置 Rails,但每当尝试运行 rails -v
、rails new app
或 bundle exec rails server
等任何命令时都会遇到此错误。我使用
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 -)"
【问题讨论】:
【参考方案1】:可能有多个版本的 Rails 设置,因为您尝试使用 rbenv
进行设置,并且错误路径指向由 rvm
安装的 rails。尝试运行以下内容:
\curl -sSL https://get.rvm.io | bash -s stable --rails
cd
进入你的项目目录,bundle i
确保 ruby gem 与您安装的版本匹配,ruby --version
【讨论】:
以上是关于运行任何 rails cmnd 时找不到“activesupport”的主要内容,如果未能解决你的问题,请参考以下文章
rails - 在生产模式下找不到 application.css 资产