一、正常流程
1、安装rvm
curl -L https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm -v
2、使用rvm安装ruby
rvm list known // 支持版本
sudo rvm install --force 2.4 // 安装所需版本
rvm list // 本地安装的
rvm remove 2.3
3、设置ruby
rvm 2.4 --default
二、可能的报错信息
1、执行安装rvm install 2.4
报错
Error running '__rvm_make install',
showing last 15 lines of /Users/RenChao/.rvm/log/1495852001_ruby-2.4.0/install.log
网说一:本地多版本Xcode,需要安装xcode命令行工具
xcode-select --install // 无效
网说二:更新rvm
rvm get stable // 无效
使用rvm安装ruby失败,最终的解决方法:下载所需的ruby版本,手动分解执行rvm install 2.4
Ruby个版本镜像地址
./configure // 配置
make // 编译
sudo make install // 安装
rvm remove ruby 2.0.0p648 // 删除rvm管理的ruby版本
ruby -v // 验证是否安装成功
2、执行gem install cocoapods
报错
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
解决方案:根据提示,命令前加sudo。
3、执行gem install cocoapods
报错
ERROR: While executing gem ... (Gem::Exception)
Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources
解决方案一:根据提示use non-HTTPS sources
,使用http源
gem source -l
gem source -r https://rubygems.org/ to remove
gem source -a http://rubygems.org/ to read
解决方案二:根据require openssl, install OpenSSL
,升级Mac的openssl
brew install openssl
rvm reinstall 2.3.0 --with-openssl-dir=brew --prefix openssl
4、sudo gem install cocoapods
安装成功,执行pod -v
报错
/Library/Ruby/Site/2.0.0/rubygems.rb:270:in `find_spec_for_exe': can't find gem cocoapods (>= 0.a) (Gem::GemNotFoundException)
from /Library/Ruby/Site/2.0.0/rubygems.rb:298:in `activate_bin_path'
from /usr/local/bin/pod:22:in `<main>'
解决方案:删除当前ruby,卸载cocoapods,重新安装
which pod
sudo rm -rf /usr/local/bin/ruby
sudo rvm install 2.4
sudo gem install cocoapods
网友评论