1.卸载cocoapods
sudo gem uninstall cocoapods
2.查看本地安装的cocoapods的相关东西
gem list --local | grep cocoapods
显示如下:
cocoapods (1.0.1)
cocoapods-core (1.0.1)
cocoapods-deintegrate (1.0.1)
cocoapods-downloader (1.1.1)
cocoapods-plugins (1.0.0)
cocoapods-search (1.0.0)
cocoapods-stats (1.0.0)
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
1.查看当前ruby的版本
ruby -v
2.升级Ruby环境,首先需要安装rvm
curl -L get.rvm.io | bash -s stable
source ~/.bashrc
source ~/.bash_profile
3.查看rvm版本
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 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
5.更换源
查看源是什么
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
6.安装cocoapod
sudo gem install -n /usr/local/bin cocoapods
7.安装本地库
pod setup