问题描述:今天打开电脑 pod search AFNetworking
过了好半天,出现错误
[!] CDN: trunk Repo update failed - 31 error(s):
CDN: trunk URL couldn't be downloaded: https://cdn.cocoapods.org/Specs/a/7/5/AFNetworking/0.10.0/AFNetworking.podspec.json, error: Net::OpenTimeout
CDN: trunk URL couldn't be downloaded: https://cdn.cocoapods.org/Specs/a/7/5/AFNetworking/0.7.0/AFNetworking.podspec.json, error: Net::OpenTimeout
CDN: trunk URL couldn't be downloaded: https://cdn.cocoapods.org/Specs/a/7/5/AFNetworking/0.9.0/AFNetworking.podspec.json, error: Net::OpenTimeout
CDN: trunk URL couldn't be downloaded: https://cdn.cocoapods.org/Specs/a/7/5/AFNetworking/1.0/AFNetworking.podspec.json, error: Net::OpenTimeout
考虑重装rvm,ruby,cocoapods
-
- 安装 RVM
RVM 是一个命令行工具,可以提供一个便捷的多版本 Ruby 环境的管理和切换。
rvm官网
1.1第一次安装 rvm
终端输入curl -L get.rvm.io | bash -s stable
- 安装 RVM
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 194 100 194 0 0 175 0 0:00:01 0:00:01 --:--:-- 175
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
报错原因:raw.githubusercontent.com 网址被墙。
解决方案:hosts文件配置 raw.githubusercontent.com 网站 IP。打开 查看IP地址网站 查看 raw.githubusercontent.com 网站的 IP。配置 hosts文件。
cd /etc
vi hosts
在hosts文件末尾加上 199.232.68.133 raw.githubusercontent.com
1.2 二次安装rvm,终端再次执行
curl -L get.rvm.io | bash -s stable
CJ@MacBook-Pro /etc % curl -L get.rvm.io | bash -s stable
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 194 100 194 0 0 21 0 0:00:09 0:00:09 --:--:-- 40
100 24535 100 24535 0 0 365 0 0:01:07 0:01:07 --:--:-- 316
curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to api.github.com:443
WARN: ...the preceeding error with code 35 occurred while fetching https://api.github.com/repos/rvm/rvm/tags
Downloading https://github.com/rvm/rvm/archive/1.29.9.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.9/1.29.9.tar.gz.asc
Installing RVM to /Users/zhx/.rvm/
Adding rvm PATH line to /Users/zhanghanxing/.profile /Users/zhanghanxing/.mkshrc /Users/zhanghanxing/.bashrc /Users/zhanghanxing/.zshrc.
Adding rvm loading line to /Users/zhanghanxing/.profile /Users/zhanghanxing/.bash_profile /Users/zhanghanxing/.zlogin.
Installation of RVM in /Users/zhx/.rvm/ is almost complete:
* To start using RVM you need to run `source /Users/zhanghanxing/.rvm/scripts/rvm`
in all your open shell windows, in rare cases you need to reopen all shell windows.
Thanks for installing RVM 🙏
Please consider donating to our open collective to help us maintain RVM.
👉 Donate: https://opencollective.com/rvm/donate
终于安装rvm成功
按照提示,终端输入 source /Users/zhx/.rvm/scripts/rvm
查看 rvm 的版本
rvm -v
rvm 1.29.9 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
rvm 已经是最新版本。
- 用 rvm 安装 ruby
查看已安装的 ruby 的版本
ruby -v
- 用 rvm 安装 ruby
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]
rvm 查看可安装的 ruby 版本
rvm list known
Warning, new version of rvm available '1.29.10', you are using older version '1.29.9'.
You can disable this warning with: echo rvm_autoupdate_flag=0 >> ~/.rvmrc
You can enable auto-update with: echo rvm_autoupdate_flag=2 >> ~/.rvmrc
You can update manually with: rvm get VERSION (e.g. 'rvm get stable')
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p551]
[ruby-]2.0.0[-p648]
[ruby-]2.1[.10]
[ruby-]2.2[.10]
[ruby-]2.3[.8]
[ruby-]2.4[.6]
[ruby-]2.5[.5]
[ruby-]2.6[.3]
[ruby-]2.7[.0-preview1]
ruby-head
# for forks use: rvm install ruby-head-<name> --url https://github.com/github/ruby.git --branch 2.2
# JRuby
jruby-1.6[.8]
jruby-1.7[.27]
jruby-9.1[.17.0]
jruby[-9.2.7.0]
jruby-head
# Rubinius
rbx-1[.4.3]
rbx-2.3[.0]
rbx-2.4[.1]
rbx-2[.5.8]
rbx-3[.107]
rbx-4[.3]
rbx-head
# TruffleRuby
truffleruby[-19.1.0]
# Opal
opal
# Minimalistic ruby implementation - ISO 30170:2012
mruby-1.0.0
mruby-1.1.0
mruby-1.2.0
mruby-1.3.0
mruby-1[.4.1]
mruby-2[.0.1]
mruby[-head]
# Ruby Enterprise Edition
ree-1.8.6
ree[-1.8.7][-2012.02]
# Topaz
topaz
# MagLev
maglev-1.0.0
maglev-1.1[RC1]
maglev[-1.2Alpha4]
maglev-head
# Mac OS X Snow Leopard Or Newer
macruby-0.10
macruby-0.11
macruby[-0.12]
macruby-nightly
macruby-head
# IronRuby
ironruby[-1.1.3]
ironruby-head
最新可安装的 ruby 版本是 2.7.0,安装 2.7.0 最新的ruby版本。(建议不要安装2.7.0,建议安装 2.7.0以下的版本)
rvm install 2.7.0

漫长的等待.....
此过程由于网络不稳定的原因可能会出错, 重新执行 rvm install 2.7.0
即可,直到安装成功。
- 安装 CocoaPods
gem install cocoapods
- 安装 CocoaPods
成功后,测试下pod. pod search AFNetWorking
/Users/zhanghanxing/.rvm/gems/ruby-2.7.0/gems/cocoapods-core-1.9.3/lib/cocoapods-core/cdn_source.rb:342: warning: URI.escape is obsolete
/Users/zhanghanxing/.rvm/gems/ruby-2.7.0/gems/cocoapods-core-1.9.3/lib/cocoapods-core/cdn_source.rb:342: warning: URI.escape is obsolete
/Users/zhanghanxing/.rvm/gems/ruby-2.7.0/gems/cocoapods-core-1.9.3/lib/cocoapods-core/cdn_source.rb:342: warning: URI.escape is obsolete
结果弹出百十行,也不知道这是什么鬼。提示uri过期的一些提示。不过过会儿,也搜索到了 AFNetWorking 库。
错误原因: 原因是 ruby 2.7.0版本的bug,此版本弃用了一些方法导致的.
解决方案:网上查了下,也没有更好的解决方案,ruby退回到 2.7.0版本以下,重新 gem install cocoapods
- rvm删除刚安装的 ruby 2.7.0 版本,重新安装ruby 2.6.3版本,把 ruby 2.6.3版本作为默认ruby 版本。
rvm remove 2.7.0 //删除2.7.0版本
rvm install 2.6.3 //安装2.6.3版本
rvm use 2.6.3 --default //把 2.6.3版本作为默认版本
rvm list //查询已经安装的 ruby 版本
- 用 2.6.3版本的ruby重新安装 CocoaPods.
gem install cocoapods
pod setup
- 用 2.6.3版本的ruby重新安装 CocoaPods.
经过了一番折腾,pod search
和 pod install
终于正常了。
在不断折腾中,成长。那些打不倒你的,只能让你变得更强大。
-
rvm install 2.6.5
遇到的问题,报错
Error running 'requirements_osx_brew_libs_install automake libtool pkg-config coreutils libyaml libksba readline zlib openssl@1.1',
please read /Users/zhx/.rvm/log/1596165170_ruby-2.6.5/package_install_automake_libtool_pkg-config_coreutils_libyaml_libksba_readline_zlib_openssl@1.1.log
Requirements installation failed with status: 1.
-
brew install sqlite
报错
Updating Homebrew...
Error: The following directories are not writable by your user:
/usr/local/sbin
/usr/local/share/man/man3
/usr/local/share/man/man5
/usr/local/share/man/man7
You should change the ownership of these directories to your user.
sudo chown -R $(whoami) /usr/local/sbin /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7
And make sure that your user has write permission.
chmod u+w /usr/local/sbin /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7
没有读写权限。按照提示 ,终端输入
sudo chown -R $(whoami) /usr/local/sbin /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7
chmod u+w /usr/local/sbin /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7
-
rvm requirements
报错
Checking requirements for osx.
Installing requirements for osx.
Updating system..........
Installing required packages: automake, libtool, pkg-config, coreutils, libyaml, libksba, zlib, openssl@1.1...........................There were package installation errors, make sure to read the log.
Try `brew tap --repair` and make sure `brew doctor` looks reasonable.
Check Homebrew requirements https://docs.brew.sh/Installation
..
Error running 'requirements_osx_brew_libs_install automake libtool pkg-config coreutils libyaml libksba zlib openssl@1.1',
please read /Users/zhx/.rvm/log/1596166910/package_install_automake_libtool_pkg-config_coreutils_libyaml_libksba_zlib_openssl@1.1.log
Requirements installation failed with status: 1.
按照提示 输入 brew tap --repair
网友评论