今天给一台刚升级过12.3.1系统的Mac电脑搭建Flutter环境,遇到一个问题,卡了好几个小时,顺带记录一下。
基础搭建就不说了,这里只说遇到的问题,当我执行sudo flutter doctor的时候,报了下边这个错误:
CocoaPods installed but not working.
You appear to have CocoaPods installed but it is not working.
This can happen if the version of Ruby that CocoaPods was installed with
is different from the one being used to invoke it.
This can usually be fixed by re-installing CocoaPods.
To re-install see
https://guides.cocoapods.org/using/getting-started.html#installation for
instructions.
我搜了各种答案,尝试重装flutter和cocoapods都不行,切换版本也不行。
直到我尝试使用flutter doctor指令,出现了下边这个错误提示:
Flutter failed to check for directory existence at
"/Users/mac/.pub-cache/hosted/pub.dartlang.org/_fe_analyzer_shared-34.0.0/lib/".
Please ensure that the SDK and/or project is installed in a location that has
read/write permissions for the current user.
Try running:
sudo chown -R $(whoami)
/Users/mac/.pub-cache/hosted/pub.dartlang.org/_fe_analyzer_shared-34.0.0
原来是权限问题,但不要用他推荐的指令,会提示zsh: permission denied: /Users/mac/.pub-cache/hosted/pub.dartlang.org/_fe_analyzer_shared-34.0.0。
用下边这句指令一句就解决了,不要问我如何知道的,死马当活马医试出来的!!!
chmod u+x /Users/XXXXX/.pub-cache/hosted/pub.dartlang.org/_fe_analyzer_shared-34.0.0
绿色部分是你电脑的用户名。