sudo gem install -n /usr/local/bin cocoapods
ERROR: 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
安装完后检查,发现还是只有一个系统目录:文章来源:https://www.toymoban.com/news/detail-645125.html
执行 which -a ruby 回车
/usr/bin/ruby
这时需要把新版本加到环境变量中: 文章来源地址https://www.toymoban.com/news/detail-645125.html
执行 which -a ruby 回车
/usr/bin/ruby
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
which -a ruby
/usr/local/opt/ruby/bin/ruby
/usr/bin/ruby
3. 安装CocoaPods:
sudo gem install -n /usr/local/bin cocoapods
到了这里,关于ERROR: While executing gem ... (Gem::FilePermissionError)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!