12

错误

Error running 'env GEM_HOME=/Users/john/.rvm/gems/ruby-2.3.8@global

2.3.8在 MacOs Catalina中尝试安装 ruby​​ 时遇到了这个错误10.15.2

$ rvm install 2.3.8


Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.15/x86_64/ruby-2.3.8.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
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/john/.rvm/rubies/ruby-2.3.8, this may take a while depending on your cpu(s)...
ruby-2.3.8 - #downloading ruby-2.3.8, this may take a while depending on your connection...
ruby-2.3.8 - #extracting ruby-2.3.8 to /Users/john/.rvm/src/ruby-2.3.8 - please wait
ruby-2.3.8 - #configuring - please wait
ruby-2.3.8 - #post-configuration - please wait
ruby-2.3.8 - #compiling - please wait
ruby-2.3.8 - #installing - please wait
ruby-2.3.8 - #making binaries executable - please wait
ruby-2.3.8 - #downloading rubygems-3.0.8
ruby-2.3.8 - #extracting rubygems-3.0.8 - please wait
ruby-2.3.8 - #removing old rubygems - please wait
ruby-2.3.8 - #installing rubygems-3.0.8 - please wait

Error running 'env GEM_HOME=/Users/john/.rvm/gems/ruby-2.3.8@global GEM_PATH= /Users/john/.rvm/rubies/ruby-2.3.8/bin/ruby -d /Users/john/.rvm/src/rubygems-3.0.8/setup.rb --no-document',

please read /Users/john/.rvm/log/1583757882_ruby-2.3.8/rubygems.install.log

日志输出

$ cat /Users/john/.rvm/log/1583757882_ruby-2.3.8/rubygems.install.log


...skipping...
Exception `LoadError' at /Users/john/.rvm/rubies/ruby-2.3.8/lib/ruby/2.3.0/rubygems.rb:1242 - cannot load such file -- rubygems/defaults/operating_system
Exception `LoadError' at /Users/john/.rvm/rubies/ruby-2.3.8/lib/ruby/2.3.0/rubygems.rb:1251 - cannot load such file -- rubygems/defaults/ruby
Exception `LoadError' at /Users/john/.rvm/rubies/ruby-2.3.8/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55 - cannot load such file -- did_you_mean
/Users/john/.rvm/src/rubygems-3.0.8/lib/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- openssl (LoadError)
        from /Users/john/.rvm/src/rubygems-3.0.8/lib/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /Users/john/.rvm/src/rubygems-3.0.8/lib/rubygems/specification.rb:2481:in `to_ruby'
        from /Users/john/.rvm/src/rubygems-3.0.8/lib/rubygems/commands/setup_command.rb:405:in `install_default_bundler_gem'
        from /Users/john/.rvm/src/rubygems-3.0.8/lib/rubygems/commands/setup_command.rb:167:in `execute'
        from /Users/john/.rvm/src/rubygems-3.0.8/lib/rubygems/command.rb:321:in `invoke_with_build_args'
        from /Users/john/.rvm/src/rubygems-3.0.8/lib/rubygems/command_manager.rb:184:in `process_args'
        from /Users/john/.rvm/src/rubygems-3.0.8/lib/rubygems/command_manager.rb:148:in `run'
        from /Users/john/.rvm/src/rubygems-3.0.8/lib/rubygems/gem_runner.rb:59:in `run'
        from setup.rb:41:in `<main>'

要点是

`require': cannot load such file -- openssl (LoadError)

我试过

深入挖掘,我发现较新版本的 OSX 弃用了 OpenSSL,导致许多依赖项被破坏。您需要重新安装 ruby​​,但要准确指定 OpenSSL 库的位置。如果您使用的是 RVM,则如下所示:

$ brew install openssl
$ rvm reinstall 2.3.8 --with-openssl-dir=`brew --prefix openssl`

但没有用,错误没有改变。

然后我尝试了

$ rvm reinstall 2.3.8 --rubygems 2.6.6 --with-openssl-dir=`brew --prefix openssl`


Error running '__rvm_with ruby-2.3.8@myapp gemset_pristine',
please read /Users/john/.rvm/log/1583758650_ruby-2.3.8/gemset.pristine-ruby-2.3.8@myapp

说,nokogiri 没有安装,

$ gem install nokogiri -v=1.10.4

ERROR:  While executing gem ... (Gem::Exception)
    Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources

知道如何解决这个问题吗?

4

2 回答 2

9

我尝试了所有方法并得出结论,ruby 2.3.8 RVMhas 的二进制文件存在问题。我RVM从系统中删除并开始使用rbenv.

用家酿

$ brew install rbenv
$ rbenv init
# Do as it says
$ rbenv install 2.3.8

还要确保您使用bundler旧代码中指定的Gemfile.lock

于 2020-03-11T03:00:10.707 回答
1

看起来旧的 ruby​​ 版本需要旧版本的 openSSL,而且它必须使用指向 --with-openssl-dir 的版本来构建

你可以试试这个:

brew install rbenv/tap/openssl@1.0

PKG_CONFIG_PATH=/usr/local/Cellar/openssl@1.0/1.0.2t/lib/pkgconfig \
rvm install 2.3.7 \
--with-openssl-dir=/usr/local/Cellar/openssl@1.0/1.0.2t \
--with-openssl-lib=/usr/local/Cellar/openssl@1.0/1.0.2t/lib \
--with-openssl-include=/usr/local/Cellar/openssl@1.0/1.0.2t/include --rubygems ignore

复制自

于 2020-12-18T11:27:33.243 回答