When running code with Ruby warnings enabled, I'm seeing circular warnings in the console. Would it be possible to fix them? When debugging the problem, I discovered that mustermann-contrib was the culprit. Specifically these two files:
If the require 'mustermann' statements at the top of these files are removed then the Ruby warnings go away. When manually removing those require statements within my local environment, my test suite still passed but without the warnings shown below.
Steps to Recreate
I wasn't able to quickly sketch together a quick snippet that would recreate the error in an isolated environment but here's what the output looks like in one of my projects:
Stack Dump
```
/Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35: warning: /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35: warning: loading in progress, circular require considered harmful - /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/mustermann-1.1.1/lib/mustermann.rb
from /var/folders/9s/b1_9vxs16lv8bg0dqgn15g_h0000gn/T/frum_1631_1653835712846/bin/bundle:25:in `'
from /var/folders/9s/b1_9vxs16lv8bg0dqgn15g_h0000gn/T/frum_1631_1653835712846/bin/bundle:25:in `load'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.14/exe/bundle:36:in `'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/site_ruby/3.1.0/bundler/friendly_errors.rb:103:in `with_friendly_errors'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.14/exe/bundle:48:in `block in '
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/site_ruby/3.1.0/bundler/cli.rb:25:in `start'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/site_ruby/3.1.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/site_ruby/3.1.0/bundler/cli.rb:31:in `dispatch'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/site_ruby/3.1.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/site_ruby/3.1.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/site_ruby/3.1.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/site_ruby/3.1.0/bundler/cli.rb:483:in `exec'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/site_ruby/3.1.0/bundler/cli/exec.rb:23:in `run'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/site_ruby/3.1.0/bundler/cli/exec.rb:58:in `kernel_load'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/site_ruby/3.1.0/bundler/cli/exec.rb:58:in `load'
from /var/folders/9s/b1_9vxs16lv8bg0dqgn15g_h0000gn/T/frum_1631_1653835712846/bin/rspec:25:in `'
from /var/folders/9s/b1_9vxs16lv8bg0dqgn15g_h0000gn/T/frum_1631_1653835712846/bin/rspec:25:in `load'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/exe/rspec:4:in `'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/runner.rb:45:in `invoke'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/runner.rb:71:in `run'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/runner.rb:89:in `run'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/runner.rb:115:in `run_specs'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/reporter.rb:74:in `report'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/runner.rb:116:in `block in run_specs'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/configuration.rb:2068:in `with_suite_hooks'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/runner.rb:121:in `block (2 levels) in run_specs'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/runner.rb:121:in `map'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/runner.rb:121:in `block (3 levels) in run_specs'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/example_group.rb:608:in `run'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/example_group.rb:608:in `map'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/example_group.rb:608:in `block in run'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/example_group.rb:607:in `run'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/example_group.rb:642:in `run_examples'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/example_group.rb:642:in `map'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/example_group.rb:646:in `block in run_examples'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/example.rb:259:in `run'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/example.rb:511:in `with_around_and_singleton_context_hooks'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/example.rb:468:in `with_around_example_hooks'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/hooks.rb:486:in `run'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/hooks.rb:624:in `run_around_example_hooks_for'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/hooks.rb:486:in `block in run'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/example.rb:468:in `block in with_around_example_hooks'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/example.rb:511:in `block in with_around_and_singleton_context_hooks'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/example.rb:263:in `block in run'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/example.rb:263:in `instance_exec'
from /Users/bkuhlmann/Engineering/OSS/janus/spec/lib/janus/integrations/jira/client_spec.rb:19:in `block (3 levels) in '
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/memoized_helpers.rb:343:in `block in let'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/memoized_helpers.rb:177:in `fetch_or_store'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/memoized_helpers.rb:177:in `fetch'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/memoized_helpers.rb:178:in `block in fetch_or_store'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-support-3.11.0/lib/rspec/support/reentrant_mutex.rb:23:in `synchronize'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/memoized_helpers.rb:179:in `block (2 levels) in fetch_or_store'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/memoized_helpers.rb:179:in `fetch'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/memoized_helpers.rb:179:in `block (3 levels) in fetch_or_store'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/memoized_helpers.rb:343:in `block (2 levels) in let'
from /Users/bkuhlmann/Engineering/OSS/janus/spec/lib/janus/integrations/jira/client_spec.rb:7:in `block (2 levels) in '
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/memoized_helpers.rb:343:in `block in let'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/memoized_helpers.rb:177:in `fetch_or_store'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/memoized_helpers.rb:177:in `fetch'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/memoized_helpers.rb:178:in `block in fetch_or_store'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-support-3.11.0/lib/rspec/support/reentrant_mutex.rb:23:in `synchronize'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/memoized_helpers.rb:179:in `block (2 levels) in fetch_or_store'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/memoized_helpers.rb:179:in `fetch'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/memoized_helpers.rb:179:in `block (3 levels) in fetch_or_store'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/memoized_helpers.rb:343:in `block (2 levels) in let'
from /Users/bkuhlmann/Engineering/OSS/janus/spec/lib/janus/integrations/jira/client_spec.rb:10:in `block (2 levels) in '
from /Users/bkuhlmann/Engineering/OSS/janus/spec/lib/janus/integrations/jira/client_spec.rb:10:in `new'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/http-fake-0.0.0/lib/http/fake/client.rb:14:in `initialize'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/http-fake-0.0.0/lib/http/fake/client.rb:14:in `new'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/http-fake-0.0.0/lib/http/fake/builder.rb:17:in `initialize'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:27:in `require'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:27:in `require'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/http-fake-0.0.0/lib/http/fake/responder.rb:3:in `'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/mustermann-1.1.1/lib/mustermann.rb:129:in `'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/mustermann-contrib-1.1.1/lib/mustermann/visualizer.rb:3:in `'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/mustermann-contrib-1.1.1/lib/mustermann/visualizer/highlight.rb:3:in `'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
from /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
```
Overview
When running code with Ruby warnings enabled, I'm seeing circular warnings in the console. Would it be possible to fix them? When debugging the problem, I discovered that
mustermann-contrib
was the culprit. Specifically these two files:If the
require 'mustermann'
statements at the top of these files are removed then the Ruby warnings go away. When manually removing thoserequire
statements within my local environment, my test suite still passed but without the warnings shown below.Steps to Recreate
I wasn't able to quickly sketch together a quick snippet that would recreate the error in an isolated environment but here's what the output looks like in one of my projects:
Stack Dump
``` /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35: warning: /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35: warning: loading in progress, circular require considered harmful - /Users/bkuhlmann/.cache/frum/versions/3.1.2/lib/ruby/gems/3.1.0/gems/mustermann-1.1.1/lib/mustermann.rb from /var/folders/9s/b1_9vxs16lv8bg0dqgn15g_h0000gn/T/frum_1631_1653835712846/bin/bundle:25:in `Environment