【问题标题】:Cannot suppress Ruby 2.7.0 warnings无法抑制 Ruby 2.7.0 警告
【发布时间】:2020-06-06 13:48:35
【问题描述】:

我跟着问题here,特地加了

export RUBYOPT='-W:no-deprecated -W:no-experimental'

到我的 .zshrc 文件。

尽管这样做,我仍然收到大量警告。例如:

/Users/XXX/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/sqlite3-1.4.1/lib/sqlite3/database.rb:89: warning: rb_check_safe_obj will be removed in Ruby 3.0
/Users/XXX/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activemodel-6.0.2.1/lib/active_model/type/integer.rb:13: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/Users/XXX/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activemodel-6.0.2.1/lib/active_model/type/value.rb:8: warning: The called method `initialize' is defined here

我不确定为什么 RUBYOPT 抑制没有被取消。

【问题讨论】:

  • 你确定设置了环境变量吗?('echo $RUBYOPT')
  • 我确实有。绝对设置 - 输出是:-W:no-deprecated -W:no-experimental

标签: ruby-on-rails ruby suppress-warnings


【解决方案1】:

我认为你应该尝试这样的测试......

RUBYOPT='-W:no-experimental -W:no-deprecated'  irb
>> Warning[:experimental]
false
>> Warning[:deprecated]
false

如果你没有看到我上面提到的输出,那就是错误的。

您没有提到产生这些警告的原始命令行。可能是您的代码中的某些内容,或者您​​正在使用的 Gem 正在更改 Warning[:deprecated] = true。这意味着您为 -W 选项输入的任何内容都将被忽略。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多