微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

RVM:无法安装 Ruby 1.9.3-p551 (macOS)

如何解决RVM:无法安装 Ruby 1.9.3-p551 (macOS)

我的 rvm 版本是 1.29.12 和 macOS 11.2.3,这是错误消息。

Error running 'env GEM_HOME=/Users/yuanyuanliu/.rvm/gems/ruby-1.9.3-p551@global GEM_PATH= /Users/yuanyuanliu/.rvm/rubies/ruby-1.9.3-p551/bin/ruby -d /Users/yuanyuanliu/.rvm/src/rubygems-2.7.9/setup.rb --no-document',please read /Users/yuanyuanliu/.rvm/log/1618286479_ruby-1.9.3-p551/rubygems.install.log

然后 cat ruby​​gems.install.log

Exception `LoadError' at /Users/yuanyuanliu/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/rubygems.rb:1264 - cannot load such file -- rubygems/defaults/operating_system
Exception `LoadError' at /Users/yuanyuanliu/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/rubygems.rb:1273 - cannot load such file -- rubygems/defaults/ruby
/Users/yuanyuanliu/.rvm/src/rubygems-3.0.9/lib/rubygems/core_ext/kernel_require.rb:54:in `require': /Users/yuanyuanliu/.rvm/src/rubygems-3.0.9/lib/rubygems/core_ext/kernel_warn.rb:15: Syntax error,unexpected tLABEL (SyntaxError)
    module_function define_method(:warn) {|*messages,uplevel: nil|
                                                              ^
/Users/yuanyuanliu/.rvm/src/rubygems-3.0.9/lib/rubygems/core_ext/kernel_warn.rb:18: void value expression
/Users/yuanyuanliu/.rvm/src/rubygems-3.0.9/lib/rubygems/core_ext/kernel_warn.rb:43: Syntax error,unexpected '}',expecting keyword_end
    from /Users/yuanyuanliu/.rvm/src/rubygems-3.0.9/lib/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /Users/yuanyuanliu/.rvm/src/rubygems-3.0.9/lib/rubygems.rb:1390:in `<top (required)>'
    from setup.rb:28:in `require'
    from setup.rb:28:in `<main>'
'command gem pristine  --version ' Failed,you need to fix these gems manually.
Error running '__rvm_with ruby-1.9.3-p551 gemset_pristine',please read /Users/yuanyuanliu/.rvm/log/1618301825_ruby-1.9.3-p551/gemset.pristine-ruby-1.9.3-p551.log
Making gemset ruby-1.9.3-p551@global pristine - please wait

'command gem pristine  --version ' Failed,you need to fix these gems manually.
Error running '__rvm_with ruby-1.9.3-p551@global gemset_pristine',please read /Users/yuanyuanliu/.rvm/log/1618301825_ruby-1.9.3-p551/gemset.pristine-ruby-1.9.3-p551@global.log

提前致谢。

解决方法

@Sam: 很多用户,比如我自己,仍然在 Ruby 1.9.3-p551 上运行生产系统,尽管每个人都尖叫着 EOL。忽略它们,因为我上次检查时,我的政府(显然是世界上最强大的)仍在运行 60 岁的 COBOL ......大声笑!嘿,如果它还能让你赚钱,为什么不呢?

无论如何,我个人更喜欢使用 rbenv 来管理我的 Ruby 版本。因此,如果您能够使用 rbenv,您可以按照我下面的说明来启动和运行 rbenvruby-1.9.3-p551 安全补丁SSLv1,SSLv2,SSLv3 & TLSv1.2:>

# 1. Update brew and install OpenSSL/rbenv
brew update
brew install openssl
brew install rbenv

# 2. Set up rbenv in your shell
rbenv init

# 3. Close your Terminal window and open a new one so your changes take effect
# 4. Verify that rbenv is properly set up using this rbenv-doctor script
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash

#  You should get a response with the following 2 last lines:
#  ----------------------------------------------------------
#> Checking RubyGems settings: OK
#> Auditing installed plugins: OK

# 5. Now,time to install Ruby 1.9.3-p551 w/ TLSv1_2 patch
# -- This process takes approx. 3-6mins on a Ubuntu 18.04 VPS
# -- Reference: https://niv.su/arch/ruby/2019/04/01/ruby1.9-openssl.html
rbenv install --force --patch 1.9.3-p551 < <(curl -sSL https://git.io/JOcZw)
# 6. Set,rbenv global and run rbenv rehash (optional)
rbenv global 1.9.3-p551
echo 'gem: --no-document' >> ~/.gemrc
rbenv rehash

# 7. Install Bunder version 1.17.3 as that is the only most recent supported 
# -- version with Ruby 1.9.3-p551
gem install bundler -v 1.17.3 --no-rdoc --no-ri
rbenv rehash

# 8. Locate your `bundle` executable and add require 'openssl' right below
# -- require 'rubygems' in that file
gem env | grep "EXECUTABLE DIRECTORY"
#> - EXECUTABLE DIRECTORY: /home/robby/.rbenv/versions/1.9.3-p551/bin
nano /home/robby/.rbenv/versions/1.9.3-p551/bin/bundle
# -- save,exit and run:
rbenv rehash
ruby -v
#> ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-linux]

# 9. At this point you should be all set and can run the following 
# -- command to ensure Ruby 1.9.3-p551 is successfully installed with the patch
curl -Lks 'https://git.io/rg-ssl' | ruby

# Your output should be similar to this except location directories for your SSL files
# -----------------------------------------------------------------
# Here's your Ruby and OpenSSL environment:
# 
# Ruby:           1.9.3p551 (2014-11-13 revision 48407) [x86_64-linux]
# RubyGems:       1.8.23.2
# Bundler:        1.17.3
# Compiled with:  OpenSSL 1.0.2n  7 Dec 2017
# SSL_CERT_FILE:  /usr/lib/ssl/cert.pem
# SSL_CERT_DIR:   /usr/lib/ssl/certs
# 
# With that out of the way,let's see if you can connect to rubygems.org...
# 
# Bundler connection to rubygems.org:       success ✅
# RubyGems connection to rubygems.org:      success ✅
# Ruby net/http connection to rubygems.org: success ✅
# 
# Hooray! This Ruby can connect to rubygems.org. You are all set to use Bundler and RubyGems. ?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。