sudo gem update -n /usr/local/bin --system gem source -l gem sources --remove 上面返回的路径 gem source -a https://gems.ruby-china.org/ sudo gem install -n /usr/local/bin cocoapods pod setup pod --version pod search AFNetWorking
如下是有可能出现的问题git
gem update --system
ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.
命令行换成github
sudo gem update --system
ERROR: While executing gem ... (Errno::EPERM) Operation not permitted - /usr/bin/update_rubygems
命令行换成json
sudo gem update -n /usr/local/bin --system
YAML safe loading is not available. Please upgrade psych to a version that supports safe loading (>= 2.0).
ruby 版本太低,更新ruby , 第一次经过RVM失败,换成了Homebrew安装成功了ruby
方式一: RVM方式安装bash
// 1.先安装ruby版本管理器RVM curl -L get.rvm.io | bash -s stable // 2.验证RVM source ~/.profile source ~/.bashrc source ~/.bash_profile // 3.测试是否安装正常 rvm -v // 4.查看ruby最新版本 rvm list known // 5.安装ruby 2.4.1 rvm install 2.4.1
方式二: Homebrew安装rubycurl
// 1.安装 Homebrew ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 若报错 error: could not lock config file /usr/local/Homebrew/.git/config: Permission denied 执行 sudo chgrp -R admin /usr/local sudo chmod -R g+w /usr/local 或 sudo chown -R $(whoami) /usr/local [参考连接] (https://apple.stackexchange.com/questions/42127/homebrew-permissions-multiple-users-needing-to-brew-update) 若报错 Error: /usr/local/Cellar is not writable. You should change the ownership and permissions of /usr/local/Cellar back to your 执行 sudo chown -R $(whoami) /usr/local/Cellar // 2.验证brew是否安装成功 brew 安装成功后,会返回 Example usage: brew search [TEXT|/REGEX/] brew (info|home|options) [FORMULA…] brew install FORMULA… brew update brew upgrade [FORMULA…] brew uninstall FORMULA… brew list [FORMULA…] // 3.更新最新版本brew brew update // 4.安装 ruby, 经过下面的命令会安装最新的ruby版本 brew install ruby // 5.安装后查看ruby版本仍是老版本 source ~/.profile source ~/.bash_profile
ERROR: SSL verification error at depth 1: unable to get local issuer certificate (20) ERROR: You must add /O=Digital Signature Trust Co./CN=DST Root CA X3 to your local trusted store
请升级rubyide
// 检查现有 Ruby镜像 gem sources -l 若是结果是 *** CURRENT SOURCES *** https://gems.ruby-china.org/ 就不须要替换了,不然就要替换,执行下面命令 // 移除现有镜像 gem sources --remove https://rubygems.org // 添加国内镜像 gem source -a https://gems.ruby-china.org/ // 检查是否替换成功 gem sources -l
sudo gem install cocoapods 若出现 ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /usr/bin directory. 则换成下面的命令行 sudo gem install -n /usr/local/bin cocoapods
pod setup
pod --version
若报错测试
[!] Unable to find a pod with name, author, summary, or description matching `AFNetworking`
执行命令行ui
rm ~/Library/Caches/CocoaPods/search_index.json
而后再执行 pod search AFNetworking ,会从新创建索引,须要花费一会时间