记录:
本来好好的可以在Xcode上运行的,然后项目跑起来失败,提示以下错误:
Warning: CocoaPods is installed but broken. Skipping pod install.
运行flutter doctor
是的,Xcode这里显示cocoapods没有安装
尝试安装
sudo gem install cocoapods
第一句就提示了警告,说没权限
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/universal-darwin21/rbconfig.rb:230: warning: Insecure world writable dir /opt/homebrew/sbin in PATH, mode 040777
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.
直接
sudo chmod 755 /opt/homebrew/bin
再次尝试安装,还是不行
百度了一下
然后参考这篇文章解决了
亲手解决错误:ERROR: While executing gem … (Gem::FilePermissionError) You don’t have write permis…
这里面有个点要注意一下(防止有些跟我一样糊里糊涂的人)
在第二步 把新版本加到环境变量中
将PATH加入~/.zshrc中,这里的PATH是安装最新版本的ruby(brew install ruby)中输出的最后这里有写
像这位作者是这样
我这里是这样
还有一个点是最后下载cocoapods
这里的路径我不太理解为啥这样写,但依葫芦画瓢,找了共同点,就是如下,新的ruby路径中/opt前的路径,然后加了/bin
如这里所示
sudo gem install -n /opt/homebrew/bin cocoapods