弃用警告中的错误 Ruby 版本
Wrong Ruby version in a deprecation warning
这是我在 Heroku 上为 运行ning 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 >
有谁知道为什么折旧警告的路径包含 Ruby 的错误版本 (2.6.0
)?
这是设计使然。将 Ruby 安装为系统可执行文件时(或使用没有显式 gem 路径的默认安装程序),gem 路径将始终使用主 Ruby 版本作为路径组件gem秒。这样您就可以更新次要版本而无需重新安装所有 gem。
所以任何 2.6.x 版本,默认情况下都会将其 gem 安装在 /...something.../2.6.0/gems
中。
使用 RVM 或 rbenv 时情况不同,您可以在其中为每个 Ruby 安装明确指定 gem 集。我们可以在您的 RVM 安装中看到这一点,其中 gemset 路径非常具体并直接绑定到特定的 Ruby 可执行文件。
这是我在 Heroku 上为 运行ning 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 >
有谁知道为什么折旧警告的路径包含 Ruby 的错误版本 (2.6.0
)?
这是设计使然。将 Ruby 安装为系统可执行文件时(或使用没有显式 gem 路径的默认安装程序),gem 路径将始终使用主 Ruby 版本作为路径组件gem秒。这样您就可以更新次要版本而无需重新安装所有 gem。
所以任何 2.6.x 版本,默认情况下都会将其 gem 安装在 /...something.../2.6.0/gems
中。
使用 RVM 或 rbenv 时情况不同,您可以在其中为每个 Ruby 安装明确指定 gem 集。我们可以在您的 RVM 安装中看到这一点,其中 gemset 路径非常具体并直接绑定到特定的 Ruby 可执行文件。