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 ,會從新創建索引,須要花費一會時間