如何在gem环境中设置正确的Ruby版本 [英] How to set correct Ruby version in gem environment

查看:468
本文介绍了如何在gem环境中设置正确的Ruby版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意:此问题与使用chruby我在macOS上安装了Ruby 1.8.7:

Using chruby I have Ruby 1.8.7 installed on macOS:

$ ruby -v
ruby 1.8.7 (2013-06-27 patchlevel 374) [i686-darwin17.4.0]

此外,我已经使用gem update --system 1.8.30安装了我希望兼容的特定版本的RubyGems.这似乎已正确安装:

Also, I have used gem update --system 1.8.30 to install a specific version of RubyGems which I am hoping is compatible. This would appear to be installed properly:

$ gem --version
1.8.30

但是,我的RubyGems环境显示了不正确的Ruby版本(2.5.0):

However, my RubyGems environment shows the incorrect version of Ruby (2.5.0):

$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.30
  - RUBY VERSION: 2.5.0 (2017-12-25 patchlevel 0) [x86_64-darwin17]
  - INSTALLATION DIRECTORY: /Users/keithpitty/.gem/ruby/1.8.7
  - RUBY EXECUTABLE: /usr/local/opt/ruby/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/keithpitty/.gem/ruby/1.8.7/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-17
  - GEM PATHS:
     - /Users/keithpitty/.gem/ruby/1.8.7
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

如何修复RubyGems环境以使用chruby设置的Ruby版本?

How can I fix the RubyGems environment to use the version of Ruby that chruby has set?

推荐答案

我缺少的步骤是从源代码安装RubyGems 1.6.2.遵循 Dan Cheail 的其他建议,我做了以下事情:

My missing step was installing RubyGems 1.6.2 from source. Following advice elsewhere from Dan Cheail, I did the following:

curl -O https://rubygems.org/rubygems/rubygems-1.6.2.tgz

(然后解压缩)

cd rubygems-1.6.2
chruby ruby-1.8.7-p374
ruby setup.rb
gem update --system 1.8.25

然后固定了我的RubyGems环境:

And then my RubyGems environment was fixed:

$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.25
  - RUBY VERSION: 1.8.7 (2013-06-27 patchlevel 374) [i686-darwin17.4.0]
  - INSTALLATION DIRECTORY: /Users/keithpitty/.gem/ruby/1.8.7
  - RUBY EXECUTABLE: /Users/keithpitty/.rubies/ruby-1.8.7-p374/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/keithpitty/.gem/ruby/1.8.7/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-darwin-17
  - GEM PATHS:
     - /Users/keithpitty/.gem/ruby/1.8.7
     - /Users/keithpitty/.rubies/ruby-1.8.7-p374/lib/ruby/gems/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

这篇关于如何在gem环境中设置正确的Ruby版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆