这是我在Heroku上运行rails控制台时得到的输出。
❯ heroku run rails console -a my-app
Running rails console on ⬢ my-app... up, run.4507 (Standard-1X)
/app/vendor/bundle/ruby/2.6.0/gems/httpi-2.4.2/lib/httpi/auth/ssl.rb:13: warning: constant OpenSSL::SSL::SSLContext::METHODS is deprecated
/app/app/lib/proxy/choose.rb:23: warning: constant Net::HTTPServerException is deprecated
Loading production environment (Rails 5.2.4.2)
irb(main):001:0>
我不明白的是,我的ruby版本是: 不 2.6.0
但 2.6.5
在我的Gemfile中指定。
在警告中显示不正确的Ruby版本不是Heroku特有的。当我在CentOS上运行rails控制台时,我得到的是这样的结果。
[my-app@pinternal2 ogirginc]$ cd /my-app-app/src/ && /usr/local/bin/envdir /my-app-app/env /usr/local/rvm/gems/ruby-2.6.5/wrappers/bundle exec rails c
/my-app-app/bundle/ruby/2.6.0/gems/httpi-2.4.2/lib/httpi/auth/ssl.rb:13: warning: constant OpenSSL::SSL::SSLContext::METHODS is deprecated
/my-app-app/src/app/lib/proxy/choose.rb:23: warning: constant Net::HTTPServerException is deprecated
Loading production environment (Rails 5.2.4.2)
2.6.5 :001 >
让我更困惑的是在我的本地机器(macOS)上运行控制台。
❯ bundle exec bin/rails console
/Users/ogirginc/.rvm/gems/ruby-2.6.5@my_app/gems/httpi-2.4.2/lib/httpi/auth/ssl.rb:13: warning: constant OpenSSL::SSL::SSLContext::METHODS is deprecated
/Users/ogirginc/.rvm/gems/ruby-2.6.5@my_app/gems/shoulda-matchers-2.8.0/lib/shoulda/matchers/active_model/validate_inclusion_of_matcher.rb:251: warning: BigDecimal.new is deprecated; use BigDecimal() method instead.
Loading development environment (Rails 5.2.4.2)
2.6.5 :001 >
有人知道为什么折旧警告的路径中包含了错误的版本吗?2.6.0
)的Ruby?
这是设计好的。当把Ruby作为系统可执行文件安装时(或使用默认的安装程序,而没有明确的gem路径),gem路径将始终使用主要的Ruby版本作为gem的路径组件。这是为了让你可以更新次要版本,而不必重新安装所有的宝石。
因此,任何2.6.x版本的宝石都会被安装在 /...something.../2.6.0/gems
默认情况下是这样的。
当使用RVM或rbenv时,情况就不一样了,你可以明确地为每个Ruby安装指定gemsets。我们可以在你的RVM安装中看到这一点,其中的gemset路径是非常具体的,并直接绑定到特定的Ruby可执行文件。