sudo gem uninstall cocoapods
git
gem list --local | grep cocoapods
github
显示以下:api
cocoapods (1.0.1)xcode
cocoapods-core (1.0.1)ruby
cocoapods-deintegrate (1.0.1)bash
cocoapods-downloader (1.1.1)app
cocoapods-plugins (1.0.0)curl
cocoapods-search (1.0.0)工具
cocoapods-stats (1.0.0)ui
cocoapods-trunk (1.0.0)
cocoapods-try (1.1.0)
而后使用命令逐个删除
sudo gem uninstall cocoapods-core
注:若是出现root用户没有/user/bin权限,那是因为系统启用了SIP(System Integerity Protection)致使root用户也没有修改权限,因此咱们须要屏蔽掉这个功能
1.重启电脑
2.command + R 进入recover模式
3.点击最上方菜单使用工具,选择终端
4.运行命令csrutil disable
5.从新启动电脑
ruby -v
curl -L get.rvm.io | bash -s stable
source ~/.bashrc
source ~/.bash_profile
rvm -v
结果: rvm 1.29.9 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [rvm.io]
4.安装rvm(版本能够经过rvm list查看能够安装的rvm的版本)
rvm install 2.5.1
注: 若是没有安装homebrew可能会报错
安装homebrew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
安装homebrew的时候可能会出现这样的错误:
报错一: error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 60
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
Error: Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core failed!
Failed during: /usr/local/bin/brew update --force
这里网上找了不少方法试了一下,最后,更换清华大学的homebrew的镜像源:
git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git
brew update
报错二: 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
而后从新执行 rvm install 2.5.1
查看源是什么 gem sources -l
gem sources --remove https://gems.ruby-china.org/
更换为 gem sources --add https://gems.ruby-china.com/
注:若是安装了多个Xcode使用下面的命令选择
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
sudo gem install -n /usr/local/bin cocoapods
pod setup