在Mac上配置flutter环境时出现了这个问题(当费劲九牛二虎只力把mac os和Xcode都升级到最新后。我的心情时奔溃的)
我使用的Android Studio,万事具备的时候运行flutter doctor 出现了下面的异常:
按照提示安装cocoapods,在终端运行 sudo gem install cocoapods时,又出现了这篇文章出现的原因:
ERROR: Could not find a valid gem 'cocoapods' (>= 0), here is why:
Unable to download data fromhttps://ruby.taobao.org/- bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)
己经百度查阅和试探各种方法都无果。。。
现将解决办法分享给大家:
打开mac终端,替换ruby-china镜像
192:~ mac$ gem sources --remove https://rubygems.org/
source https://rubygems.org/ not present in cache
192:~ mac$ gem sources --remove https://ruby.taobao.org/
source https://ruby.taobao.org/ not present in cache
192:~ mac$ gem sources -a https://gems.ruby-china.com/
https://gems.ruby-china.com/ added to sources
验证你的ruby镜像是不是ruby-china
192:~ mac$ gem sources -l
*** CURRENT SOURCES ***
https://gems.ruby-china.com/
192:~ mac$ sudi gem update --system
-bash: sudi: command not found
192:~ mac$ sudo gem update --system
Password:
Latest version already installed. Done.
安装最新版本的 cocoapods
192:~ mac$ sudo gem install -n /usr/local/bin cocoapods
Fetching ffi-1.12.2.gem
Successfully installed thread_safe-0.3.6
.
.
.
Installing ri documentation for cocoapods-1.9.1
Done installing documentation for thread_safe, tzinfo, concurrent-ruby, i18n, activesupport, nap, fuzzy_match, httpclient, algoliasearch, ffi, ethon, typhoeus, netrc, cocoapods-core, claide, cocoapods-deintegrate, cocoapods-downloader, cocoapods-plugins, cocoapods-search, cocoapods-stats, cocoapods-trunk, cocoapods-try, molinillo, atomos, colored2, nanaimo, xcodeproj, escape, fourflusher, gh_inspector, ruby-macho, cocoapods after 56 seconds
32 gems installed
成功~~