一、安裝 ruby 環(huán)境
- 查看 version 列表
> rvm list known
- 運(yùn)行結(jié)果
# MRI Rubies
[ruby-]1.8.6[-p420]
....
[ruby-]2.5[.7]
[ruby-]2.6[.5]
[ruby-]2.7[.0]
ruby-head
- 安裝 ruby 指定版本
> gem install 2.7
- 運(yùn)行結(jié)果
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.15/x86_64/ruby-2.6.5.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Updating certificates bundle '/usr/local/etc/openssl@1.1/cert.pem'
Requirements installation successful.
Installing Ruby from source to: /Users/jack/.rvm/rubies/ruby-2.6.5, this may take a while depending on your cpu(s)...
ruby-2.6.5 - #downloading ruby-2.6.5, this may take a while depending on your connection...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
Warning: Transient problem: timeout Will retry in 2 seconds. 1 retries left.
0 0 0 0 0 0 0 0 --:--:-- 0:00:30 --:--:-- 0
curl: (28) Connection timed out after 30001 milliseconds
There was an error(28).
Checking fallback: https://ftp.ruby-lang.org/pub/ruby/2.6/ruby-2.6.5.tar.bz2
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 13.4M 100 13.4M 0 0 31994 0 0:07:21 0:07:21 --:--:-- 72231
No checksum for downloaded archive, recording checksum in user configuration.
ruby-2.6.5 - #extracting ruby-2.6.5 to /Users/jack/.rvm/src/ruby-2.6.5 - please wait
ruby-2.6.5 - #configuring - please wait
ruby-2.6.5 - #post-configuration - please wait
ruby-2.6.5 - #compiling - please wait
Error running '__rvm_make -j4',
please read /Users/jack/.rvm/log/1592793830_ruby-2.6.5/make.log
There has been an error while running make. Halting the installation.
二憔儿、錯(cuò)誤分析
查看 /Users/jack/.rvm/log/1592793830_ruby-2.6.5/make.log
日志磷醋,基本是因?yàn)閤code環(huán)境和 openssl導(dǎo)致編譯失敗
...
CFLAGS = -O3 -ggdb3 -Wall -Wextra -Wdeclaration-after-statement -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -fno-common -pipe
XCFLAGS = -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fno-strict-overflow -fvisibility=hidden -DRUBY_EXPORT -DCANONICALIZATION_FOR_MATHN
CPPFLAGS = -I/usr/local/opt/libyaml/include -I/usr/local/opt/libksba/include -I/usr/local/opt/readline/include -I/usr/local/opt/zlib/include -I/usr/local/opt/openssl@1.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -I. -I.ext/include/x86_64-darwin19 -I./include -I. -I./enc/unicode/12.1.0
DLDFLAGS = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -L/usr/local/opt/libyaml/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/zlib/lib -L/usr/local/opt/openssl@1.1/lib -install_name /Users/jack/.rvm/rubies/ruby-2.6.5/lib/libruby.2.6.dylib -compatibility_version 2.6 -current_version 2.6.5 -fstack-protector-strong -framework Security -framework Foundation -fstack-protector-strong -framework Security -framework Foundation
SOLIBS = -lpthread -ldl -lobjc
LANG = zh_CN.UTF-8
LC_ALL =
LC_CTYPE = zh_CN.UTF-8
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: x86_64-apple-darwin19.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
...
三屿岂、解決方案一
- 重新安裝 xcode-select (安裝失敗可升級(jí)系統(tǒng)或網(wǎng)絡(luò))
xcode-select --install
- 重新執(zhí)行
gem install
(openssl 是使用 brew 安裝的吴裤,重新指定一下 openssl 路徑)
rvm install 2.6.5 --with-openssl-dir='brew --prefix openssl'
- 運(yùn)行結(jié)果
mruby-1.3.0 - #removing src/mruby-1.3.0 - please wait
mruby-1.3.0 - #removing rubies/mruby-1.3.0 - please wait
RVM does not have prediction for required space for mruby-1.3.0, assuming 150MB should be enough, let us know if it was not.
Checking requirements for osx.
Certificates bundle '/usr/local/etc/openssl@1.1/cert.pem' is already up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/jack/.rvm/rubies/mruby-1.3.0, this may take a while depending on your cpu(s)...
mruby-1.3.0 - #downloading 1.3.0, this may take a while depending on your connection...
mruby-1.3.0 - #extracting 1.3.0 to /Users/jack/.rvm/src/mruby-1.3.0 - please wait
mruby-1.3.0 - #compiling - please wait
mruby-1.3.0 - #installing - please wait
Install of mruby-1.3.0 - #complete
Required ruby-2.7.0 is not installed.
To install do: 'rvm install "ruby-2.7.0"'
四继蜡、解決方案二
使用 reinstall
重新安裝
> rvm reinstall ruby --disable-binary
- 運(yùn)行結(jié)果
mruby-1.3.0 - #removing src/mruby-1.3.0 - please wait
mruby-1.3.0 - #removing rubies/mruby-1.3.0 - please wait
RVM does not have prediction for required space for mruby-1.3.0, assuming 150MB should be enough, let us know if it was not.
Checking requirements for osx.
Certificates bundle '/usr/local/etc/openssl@1.1/cert.pem' is already up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/jack/.rvm/rubies/mruby-1.3.0, this may take a while depending on your cpu(s)...
mruby-1.3.0 - #downloading 1.3.0, this may take a while depending on your connection...
mruby-1.3.0 - #extracting 1.3.0 to /Users/jack/.rvm/src/mruby-1.3.0 - please wait
mruby-1.3.0 - #compiling - please wait
mruby-1.3.0 - #installing - please wait
Install of mruby-1.3.0 - #complete
Required ruby-2.7.0 is not installed.
To install do: 'rvm install "ruby-2.7.0"'
默認(rèn)安裝最新版本