问题
执行sudo gem install cocoapods
报错
错误内容
Successfully installed algoliasearch-1.27.5
Successfully installed fuzzy_match-2.0.4
Successfully installed tzinfo-2.0.6
Successfully installed i18n-1.14.1
ERROR: Error installing cocoapods:
The last version of activesupport (>= 5.0, < 8) to support your Ruby & RubyGems was 6.1.7.6. Try installing it with `gem install activesupport -v 6.1.7.6` and then running the current command again
activesupport requires Ruby version >= 2.7.0. The current ruby version is 2.6.8.205.
解决方案
升级ruby版本到3.2.2
# 安装rbenv和ruby-build
brew install rbenv ruby-build
# 安装ruby 3.2.2版本
rbenv install 3.2.2
# 设置3.2.2为默认ruby版本
rbenv global 3.2.2
修改.zshrc
配置
在.zshrc
后面追加内容
# ruby
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
# ruby end
然后执行
source ~/.zshrc