When running my tests in a Rails application, I see the following deprecation warning multiple times:
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)
However, I don’t have any code in my application that uses color, bold, or anything related to formatting log text. The warning doesn’t point to a specific file or line in my code, so I’m not sure what’s triggering it.
Here is some additional context:
Rails version: 7.1.4.1, Rspec
Has anyone found a way to resolve this issue when running tests in these Rails versions without needing to upgrade the Rails gem?
Thank you in advance!
Are you using Kredis? If so, this might be in the pipeline and you might need to update this dependency when it's merged: https://github.com/rails/kredis/issues/108
In any case, this looks tricky as the stack trace is not very useful. There are at least two ways that might lead you to the source:
Set ActiveSupport::Deprecation.debug = true
in your config/environments/test.rb
this should throw an exception instead of deprecation warning, and maybe the stacktrace is more useful (this should really be enough and the other suggestions should not be needed unless something really weird is going on) (kudos to How can I configure Rails to raise an error when it hits a deprecation warning?)
bundle open rails
in your project, and try finding the place the deprecation is emitted (look for ActiveSupport::Deprecation
or just Deprecation
or deprecate
), set up a breakpoint, run specs and explore the frames when debugger pauses.
set your bundler to install gems locally (using BUNDLE_PATH) and grep the directory for usages of ActiveSupport::LogSubscriber
and see if any looks like it's using the #color
method the old way.