这是我在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>我不明白的是,我的红宝石版本是,不是 2.6.0,而是Gemfile中指定的2.6.5。
在警告中显示不正确的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吗?
发布于 2020-05-23 19:38:12
这是故意的。当将Ruby安装为系统可执行文件(或者使用默认安装程序而不使用显式宝石路径)时,gem路径将始终使用主要的Ruby版本作为gems的path组件。这是为了使您可以更新次要版本,而不必重新安装所有的宝石。
因此,在默认情况下,任何2.6.x版本都将在/...something.../2.6.0/gems中安装其gems。
当使用RVM或rbenv时,情况就不同了,在RVM或rbenv中,您可以为每个Ruby安装显式地指定您的宝石集。我们可以在您的RVM安装中看到这一点,在RVM中,RVM路径非常具体,并且直接绑定到特定的Ruby可执行文件。
https://stackoverflow.com/questions/61976085
复制相似问题