Error while installing Ruby 2.3.7 in mac os 10.15.5 Catalina using RVM; OpenSSL not found

£可爱£侵袭症+ 提交于 2021-02-08 06:50:58

问题


I am trying to install ruby using below commands

source ~/.rvm/scripts/rvm
rvm install 2.3.7

I encountered this error while I was trying to install ruby 2.3.7 in MacOs Catalina 10.15.5

rvm install 2.3.7
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')

Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.15/x86_64/ruby-2.3.7.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Installing requirements for osx.
Updating system..........
Installing required packages: openssl.
Updating certificates bundle '/usr/local/etc/openssl@1.1/cert.pem'
Requirements installation successful.
Installing Ruby from source to: /Users/pusingh/.rvm/rubies/ruby-2.3.7, this may take a while depending on your cpu(s)...
ruby-2.3.7 - #downloading ruby-2.3.7, this may take a while depending on your connection...
ruby-2.3.7 - #extracting ruby-2.3.7 to /Users/pusingh/.rvm/src/ruby-2.3.7.....
ruby-2.3.7 - #configuring...........................................................
ruby-2.3.7 - #post-configuration.
ruby-2.3.7 - #compiling..............................................................
ruby-2.3.7 - #installing.........
ruby-2.3.7 - #making binaries executable..
ruby-2.3.7 - #downloading rubygems-3.0.8
ruby-2.3.7 - #extracting rubygems-3.0.8......
ruby-2.3.7 - #removing old rubygems.........
$LANG was empty, setting up LANG=en_US.US-ASCII, if it fails again try setting LANG to something sane and try again.
ruby-2.3.7 - #installing rubygems-3.0.8..
Error running 'env GEM_HOME=/Users/pusingh/.rvm/gems/ruby-2.3.7@global GEM_PATH= /Users/pusingh/.rvm/rubies/ruby-2.3.7/bin/ruby -d /Users/pusingh/.rvm/src/rubygems-3.0.8/setup.rb --no-document',
please read /Users/pusingh/.rvm/log/1591718224_ruby-2.3.7/rubygems.install.log

this is the output of rubygems.install.log file -

Users/pusingh/.rvm/rubies/ruby-2.3.7/bin/ruby
current path: /Users/pusingh/.rvm/src/rubygems-3.0.8
GEM_HOME=/Users/pusingh/.rvm/gems/ruby-2.3.7@pm
PATH=/Users/pusingh/.rvm/usr/bin:/usr/local/opt/coreutils/bin:/usr/local/opt/pkg-config/bin:/usr/local/opt/libtool/bin:/usr/local/opt/automake/bin:/usr/local/opt/autoconf/bin:/Users/pusingh/.rvm/gems/ruby-2.3.7@pm/bin:/Users/pusingh/.rvm/gems/ruby-2.3.7@global/bin:/Users/pusingh/.rvm/rubies/ruby-2.3.7/bin:/Users/pusingh/.rvm/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
GEM_PATH=/Users/pusingh/.rvm/gems/ruby-2.3.7@pm:/Users/pusingh/.rvm/gems/ruby-2.3.7@global
command(7): env GEM_HOME=/Users/pusingh/.rvm/gems/ruby-2.3.7@global GEM_PATH= /Users/pusingh/.rvm/rubies/ruby-2.3.7/bin/ruby -d /Users/pusingh/.rvm/src/rubygems-3.0.8/setup.rb --no-document
Exception `LoadError' at /Users/pusingh/.rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/rubygems.rb:1242 - cannot load such file -- rubygems/defaults/operating_system
Exception `LoadError' at /Users/pusingh/.rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/rubygems.rb:1251 - cannot load such file -- rubygems/defaults/ruby
Exception `LoadError' at /Users/pusingh/.rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55 - cannot load such file -- did_you_mean
/Users/pusingh/.rvm/src/rubygems-3.0.8/lib/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- openssl (LoadError)
    from /Users/pusingh/.rvm/src/rubygems-3.0.8/lib/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /Users/pusingh/.rvm/src/rubygems-3.0.8/lib/rubygems/specification.rb:2481:in `to_ruby'
    from /Users/pusingh/.rvm/src/rubygems-3.0.8/lib/rubygems/commands/setup_command.rb:405:in `install_default_bundler_gem'
    from /Users/pusingh/.rvm/src/rubygems-3.0.8/lib/rubygems/commands/setup_command.rb:167:in `execute'
    from /Users/pusingh/.rvm/src/rubygems-3.0.8/lib/rubygems/command.rb:321:in `invoke_with_build_args'
    from /Users/pusingh/.rvm/src/rubygems-3.0.8/lib/rubygems/command_manager.rb:184:in `process_args'
    from /Users/pusingh/.rvm/src/rubygems-3.0.8/lib/rubygems/command_manager.rb:148:in `run'
    from /Users/pusingh/.rvm/src/rubygems-3.0.8/lib/rubygems/gem_runner.rb:59:in `run'
    from setup.rb:41:in `<main>'

open ssl version is OpenSSL> version LibreSSL 2.8.3

Please help as I am not sure what is going wrong


回答1:


See this issue comment

It looks like old ruby version requires an older version of openSSL and also it has to be build with that version pointing in --with-openssl-dir

You might try this:

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



回答2:


For older versions of ruby, you might want to use a docker + docker-compose development workflow like this one. https://rollout.io/blog/running-rails-development-environment-docker/

You should be able to install ruby 2.3 that way and you won't have to deal with these types of weird errors, plus you'll learn docker. You should be able to develop and see the changes in the images. IIRC the only issue is on gem changes you need to run a new docker-compose build.

https://rollout.io/blog/running-rails-development-environment-docker/



来源:https://stackoverflow.com/questions/62288633/error-while-installing-ruby-2-3-7-in-mac-os-10-15-5-catalina-using-rvm-openssl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!