在 Rails 应用程序中运行测试时,我多次看到以下弃用警告:
DEPRECATION WARNING: Bolding log text with a positional boolean is deprecated and will be removed in Rails 7.2. Use an option hash instead (eg. `color("my text", :red, bold: true)`). (called from tap at <internal:kernel>:90)
DEPRECATION WARNING: Bolding log text with a positional boolean is deprecated and will be removed in Rails 7.2. Use an option hash instead (eg. `color("my text", :red, bold: true)`). (called from tap at <internal:kernel>:90)
DEPRECATION WARNING: Bolding log text with a positional boolean is deprecated and will be removed in Rails 7.2. Use an option hash instead (eg. `color("my text", :red, bold: true)`). (called from tap at <internal:kernel>:90)
DEPRECATION WARNING: Bolding log text with a positional boolean is deprecated and will be removed in Rails 7.2. Use an option hash instead (eg. `color("my text", :red, bold: true)`). (called from tap at <internal:kernel>:90)
DEPRECATION WARNING: Bolding log text with a positional boolean is deprecated and will be removed in Rails 7.2. Use an option hash instead (eg. `color("my text", :red, bold: true)`). (called from tap at <internal:kernel>:90)
DEPRECATION WARNING: Bolding log text with a positional boolean is deprecated and will be removed in Rails 7.2. Use an option hash instead (eg. `color("my text", :red, bold: true)`). (called from tap at <internal:kernel>:90)
DEPRECATION WARNING: Bolding log text with a positional boolean is deprecated and will be removed in Rails 7.2. Use an option hash instead (eg. `color("my text", :red, bold: true)`). (called from tap at <internal:kernel>:90)
DEPRECATION WARNING: Bolding log text with a positional boolean is deprecated and will be removed in Rails 7.2. Use an option hash instead (eg. `color("my text", :red, bold: true)`). (called from tap at <internal:kernel>:90)
DEPRECATION WARNING: Bolding log text with a positional boolean is deprecated and will be removed in Rails 7.2. Use an option hash instead (eg. `color("my text", :red, bold: true)`). (called from tap at <internal:kernel>:90)
但是,我的应用程序中没有任何使用颜色、粗体或与格式化日志文本相关的任何代码。该警告并未指向我的代码中的特定文件或行,因此我不确定是什么触发了它。
这里有一些额外的背景信息:
Rails 版本:7.1.4.1,Rspec
在这些 Rails 版本中运行测试时,有没有人找到解决此问题的方法,而无需升级 Rails gem?
提前谢谢您!
您在使用 Kredis 吗?如果是这样,这可能在管道中,您可能需要在合并时更新此依赖项:https://github.com/rails/kredis/issues/108
无论如何,这看起来很棘手,因为堆栈跟踪不是很有用。至少有两种方法可以引导您找到来源:
在你的
ActiveSupport::Deprecation.debug = true
中设置config/environments/test.rb
,这应该抛出异常而不是弃用警告,也许堆栈跟踪更有用(这应该足够了,不需要其他建议,除非发生了非常奇怪的事情) (感谢如何配置 Rails 在遇到弃用警告时引发错误?)
bundle open rails
或只是
ActiveSupport::Deprecation
或 Deprecation
),设置断点,运行规范并在调试器暂停时探索帧。
将您的捆绑器设置为在本地安装 gem(使用 BUNDLE_PATH)并 grep 目录以查找 deprecate
ActiveSupport::LogSubscriber
方法。