sudo gem install -n /usr/local/bin cocoapodsERROR: While executing gem ... (Gem::FilePermissionError)You don't have write permissions for the /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0 directory.
解决办法:
1.删除CocoaPods;
2.用命令"which -a ruby",查看只有一个系统自带的ruby目录。
执行 which -a ruby 回车/usr/bin/ruby
需要自己再安装一个最新版本的ruby:
解决:重新安装Ruby再安装其他命令即可
brew install ruby
安装完后检查,发现还是只有一个系统目录:
执行 which -a ruby 回车/usr/bin/ruby
这时需要把新版本加到环境变量中:
执行 which -a ruby 回车/usr/bin/ruby
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc
source ~/.zshrcwhich -a ruby
/usr/local/opt/ruby/bin/ruby
/usr/bin/ruby
3. 安装CocoaPods:
sudo gem install -n /usr/local/bin cocoapods