安装 CocoaPods 有两种方式
sudo gem install cocoapods
和
brew install cocoapods
本身也不复杂,但是如果电脑上 Ruby
环境有问题的话,安装过程中会遇到一些错误,下面依次进行排查。
1. 使用brew
安装完 CocoaPods 之后
电脑之前使用了rvm
安装过 ruby,手动删除了一个3.0.0
版本,这个错误是 ruby 环境导致。
需要将 Ruby 删除干净,从头安装。
2. 使用 rvm 安装 ruby 报错
执行rvm install ruby-3.0.0
,报错如下:
给出文本各式(方便检索):
Searching for binary rubies, this might take some time.
Found remote file https://rvm_io.global.ssl.fastly.net/binaries/osx/13.3/arm64/ruby-3.0.0.tar.bz2
Checking requirements for osx.
Certificates bundle '/opt/homebrew/etc/[email protected]/cert.pem' is already up to date.
Requirements installation successful.
ruby-3.0.0 - #configure
ruby-3.0.0 - #download
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:10 --:--:-- 0
curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to rvm_io.global.ssl.fastly.net:443
There was an error(35).
Checking fallback: ftp://rvm_io.global.ssl.fastly.net/binaries/osx/13.3/arm64/ruby-3.0.0.tar.bz2?rvm=1.29.12
Checking fallback: https://www.mirrorservice.org/sites/rvm_io.global.ssl.fastly.net/binaries/osx/13.3/arm64/ruby-3.0.0.tar.bz2?rvm=1.29.12
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:02 --:--:-- 0
curl: (22) The requested URL returned error: 404 Not Found
The requested url does not exist(22): 'https://www.mirrorservice.org/sites/rvm_io.global.ssl.fastly.net/binaries/osx/13.3/arm64/ruby-3.0.0.tar.bz2?rvm=1.29.12'
Failed download
Downloading https://rvm_io.global.ssl.fastly.net/binaries/osx/13.3/arm64/ruby-3.0.0.tar.bz2 failed.
Mounting remote ruby failed with status 2, trying to compile.
Checking requirements for osx.
Certificates bundle '/opt/homebrew/etc/[email protected]/cert.pem' is already up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/gtts/.rvm/rubies/ruby-3.0.0, this may take a while depending on your cpu(s)...
ruby-3.0.0 - #downloading ruby-3.0.0, this may take a while depending on your connection...
ruby-3.0.0 - #extracting ruby-3.0.0 to /Users/gtts/.rvm/src/ruby-3.0.0 - please wait
ruby-3.0.0 - #configuring - please wait
Error running ' CFLAGS=-O3 -I/opt/homebrew/opt/libyaml/include -I/opt/homebrew/opt/libksba/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/zlib/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/libyaml/include -I/opt/homebrew/opt/libksba/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/zlib/include -I/opt/homebrew/opt/[email protected]/include LDFLAGS=-L/opt/homebrew/opt/libyaml/lib -L/opt/homebrew/opt/libksba/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/zlib/lib -L/opt/homebrew/opt/[email protected]/lib -L/opt/homebrew/opt/libyaml/lib -L/opt/homebrew/opt/libksba/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/zlib/lib -L/opt/homebrew/opt/[email protected]/lib ./configure --prefix=/Users/gtts/.rvm/rubies/ruby-3.0.0 --disable-install-doc --enable-shared',
please read /Users/gtts/.rvm/log/1683023338_ruby-3.0.0/configure.log
There has been an error while running configure. Halting the installation.
解决方式
安装OpenSSL
,如果已经安装了,则不用安装
brew install openssl
或者可以重新安装:brew reinstall openssl@3
在 Mac 的 M 芯片电脑上,HomeBrew 的安装的openssl
目录/opt/homebrew/Cellar/openssl@3/3.1.0
接下来,指定openssl 目录,安装 ruby ,即可顺利完成。
rvm install ruby-3.2.2 --with-openssl-dir=/opt/homebrew/Cellar/openssl
发表回复