1、
检查rvm是否安装:
rvm -v
若rvm未安装,执行:
curl -L get.rvm.io | bash -s stable
安装完成切换到rvm环境:
source ~/.bashrc
source ~/.bash_profile
2、
检查ruby是否安装:
ruby -v
检查rvm中是否能查找ruby:
rvm list
若rvm中找不到ruby,执行:
rvm list known
若此时brew未安装,可以提前安装,执行:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
安装列表中最新的ruby(最好大于或等于2.6.3):
rvm install 2.6.3
a、可能出现brew报错,提示Requirements installation failed with status: 1. 执行:
rvm get head
b、可能出现brew卡死,强制退出终端后,提示Error: Another active Homebrew update process is already in progress.Please wait for it to finish or terminate it to continue. 执行:
rm -rf /usr/local/var/homebrew/locks
c、可能出现brew安装过,需要卸载旧版本,执行:
rm -rf Cellar Frameworks Homebrew
再次执行:
rvm install 2.6.3
设置当前默认的ruby版本:
rvm use 2.6.3 —default
3、
查看gem的源:
Gem sources -l
若为默认的国外的源地址,执行更换gem的源:
gem sources —remove https://rubygems.org/
gem sources -a https://gems.ruby-china.com
更新升级gem版本:
Sudo gem update -n /usr/local/bin -system
4、
若安装过cocoapods,执行移除:
sudo gem uninstall cocoapods
执行安装cocoapods:
sudo gem install -n /usr/local/bin cocoapods
新版cocoapods此时的repo是空的,执行镜像替换,网络限制可能执行多次:
cd ~/.cocoapods/repos
pod repo remove master
git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git master
此时search命令无法使用,执行index重新生成:
pod setup
rm ~/Library/Caches/Cocoapods/search_index.json
执行重新搜索生成index:
pod search AFNetworking
附录:
清华大学开源软件镜像站:https://mirror.tuna.tsinghua.edu.cn/help/CocoaPods/
网友评论