Skip to content

Conversation

@benoittgt
Copy link

@benoittgt benoittgt commented Oct 30, 2025

With more recent Rails (8.1.1), it is not longer possible to start the app.

TSort::Cyclic: topological sort failed: [#<Rails::Initializable::Initializer:0x00007ff45d8c42f0 @group=:default, @name=:logstasher, @before=:load_config_initializers, @after=nil, @context=#<LogStasher::Railtie>, @block=#<Proc:0x00007ff4653371b8 /home/circleci/project/vendor/bundle/ruby/3.4.0/gems/logstasher-2.1.5/lib/logstasher/railtie.rb:43>>, #<Rails::Initializable::Initializer:0x00007ff45d8c4250 @group=:default, @name=:logstasher, @before=nil, @after=:logstasher, @context=#<LogStasher::Railtie>, @block=#<Proc:0x00007ff465b2cd50 /home/circleci/project/vendor/bundle/ruby/3.4.0/gems/logstasher-2.1.5/lib/logstasher/railtie.rb:56>>] (TSort::Cyclic)

Because of duplicated initializer.

gem 'logstasher', github: 'benoittgt/logstasher', ref: 'ae26959d64aa49afa0a6929dfd4d83a8df4eed15' to test it on your projects.

Fix: #186

TSort::Cyclic: topological sort failed: [#<Rails::Initializable::Initializer:0x00007ff45d8c42f0 @group=:default, @name=:logstasher, @before=:load_config_initializers, @after=nil, @context=#<LogStasher::Railtie>, @block=#<Proc:0x00007ff4653371b8 /home/circleci/project/vendor/bundle/ruby/3.4.0/gems/logstasher-2.1.5/lib/logstasher/railtie.rb:43>>, #<Rails::Initializable::Initializer:0x00007ff45d8c4250 @group=:default, @name=:logstasher, @before=nil, @after=:logstasher, @context=#<LogStasher::Railtie>, @block=#<Proc:0x00007ff465b2cd50 /home/circleci/project/vendor/bundle/ruby/3.4.0/gems/logstasher-2.1.5/lib/logstasher/railtie.rb:56>>] (TSort::Cyclic)
@benoittgt
Copy link
Author

@shadabahmed if you have time to look at it. 👍

@shadabahmed
Copy link
Owner

@shadabahmed if you have time to look at it. 👍

Thanks for the fix. I'll merge and build a new release today or tomorrow

@benoittgt
Copy link
Author

Thanks

Like\
```
     1.1) Failure/Error: logger << "#{LogStasher.build_logstash_event(data, tags).to_json}\n"

            LogStasher received :build_logstash_event with unexpected arguments
              expected: (hash_including(:identifier=>"text template", :layout=>nil, :name=>"render_template.action_view", :request_id=>0, :ip=>"0.0.0.0", :route=>"#"), *(any args))
                   got: ({:action=>nil, :controller=>nil, :duration=>59.56, :error=>"AbstractController::DoubleRenderError\nRe...ormat=>:html, :ip=>"0.0.0.0", :method=>"GET", :path=>"/", :request_id=>0, :route=>"#", :status=>500}, ["request", "exception"])
            Diff:
            @@ -1,2 +1,13 @@
            -["hash_including(:identifier=>\"text template\", :layout=>nil, :name=>\"render_template.action_view\", :request_id=>0, :ip=>\"0.0.0.0\", :route=>\"#\")",
            - "*(any args)"]
            +[{:action=>nil,
            +  :controller=>nil,
            +  :duration=>59.56,
            +  :error=>
            +   "AbstractController::DoubleRenderError\nRender and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like \"redirect_to(...); return\".\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/actionpack-7.2.3/lib/action_controller/metal/rendering.rb:166:in `render'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/actionpack-7.2.3/lib/action_controller/metal/instrumentation.rb:32:in `block (2 levels) in render'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/benchmark-0.5.0/lib/benchmark.rb:337:in `ms'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/actionpack-7.2.3/lib/action_controller/metal/instrumentation.rb:32:in `block in render'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/actionpack-7.2.3/lib/action_controller/metal/instrumentation.rb:101:in `cleanup_view_runtime'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/actionpack-7.2.3/lib/action_controller/metal/instrumentation.rb:31:in `render'\n/home/runner/work/logstasher/logstasher/spec/integration_spec.rb:74:in `index'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/actionpack-7.2.3/lib/action_controller/metal/basic_implicit_render.rb:8:in `send_action'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/actionpack-7.2.3/lib/abstract_controller/base.rb:215:in `process_action'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/actionpack-7.2.3/lib/action_controller/metal/rendering.rb:193:in `process_action'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/actionpack-7.2.3/lib/abstract_controller/callbacks.rb:261:in `block in process_action'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/activesupport-7.2.3/lib/active_support/callbacks.rb:101:in `run_callbacks'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/actionpack-7.2.3/lib/abstract_controller/callbacks.rb:260:in `process_action'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/actionpack-7.2.3/lib/action_controller/metal/rescue.rb:27:in `process_action'\n/home/runner/work/logstasher/logstasher/lib/logstasher/rails_ext/action_controller/metal/instrumentation.rb:40:in `block in process_action'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/activesupport-7.2.3/lib/active_support/notifications.rb:210:in `block in instrument'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/activesupport-7.2.3/lib/active_support/notifications/instrumenter.rb:58:in `instrument'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/activesupport-7.2.3/lib/active_support/notifications.rb:210:in `instrument'\n/home/runner/work/logstasher/logstasher/lib/logstasher/rails_ext/action_controller/metal/instrumentation.rb:27:in `process_action'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/actionpack-7.2.3/lib/action_controller/metal/params_wrapper.rb:259:in `process_action'\n/home/runner/work/logstasher/logstasher/lib/logstasher/rails_ext/action_controller/base.rb:11:in `process_action'\n/home/runner/work/logstasher/logstasher/spec/integration_spec.rb:46:in `block (4 levels) in <top (required)>'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.13.6/lib/rspec/core/example.rb:263:in `instance_exec'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.13.6/lib/rspec/core/example.rb:263:in `block in run'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.13.6/lib/rspec/core/example.rb:511:in `block in with_around_and_singleton_context_hooks'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.13.6/lib/rspec/core/example.rb:468:in `block in with_around_example_hooks'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.13.6/lib/rspec/core/hooks.rb:486:in `block in run'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.13.6/lib/rspec/core/hooks.rb:624:in `run_around_example_hooks_for'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.13.6/lib/rspec/core/hooks.rb:486:in `run'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.13.6/lib/rspec/core/example.rb:468:in `with_around_example_hooks'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.13.6/lib/rspec/core/example.rb:511:in `with_around_and_singleton_context_hooks'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.13.6/lib/rspec/core/example.rb:259:in `run'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.13.6/lib/rspec/core/example_group.rb:653:in `block in run_examples'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.13.6/lib/rspec/core/example_group.rb:649:in `map'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.13.6/lib/rspec/core/example_group.rb:649:in `run_examples'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.13.6/lib/rspec/core/example_group.rb:614:in `run'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.13.6/lib/rspec/core/example_group.rb:615:in `block in run'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.13.6/lib/rspec/core/example_group.rb:615:in `map'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.13.6/lib/rspec/core/example_group.rb:615:in `run'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.13.6/lib/rspec/core/example_group.rb:615:in `block in run'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.13.6/lib/rspec/core/example_group.rb:615:in `map'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.13.6/lib/rspec/core/example_group.rb:615:in `run'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.13.6/lib/rspec/core/runner.rb:121:in `block (3 levels) in run_specs'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.13.6/lib/rspec/core/runner.rb:121:in `map'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.13.6/lib/rspec/core/runner.rb:121:in `block (2 levels) in run_specs'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.13.6/lib/rspec/core/configuration.rb:2097:in `with_suite_hooks'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.13.6/lib/rspec/core/runner.rb:116:in `block in run_specs'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.13.6/lib/rspec/core/reporter.rb:74:in `report'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.13.6/lib/rspec/core/runner.rb:115:in `run_specs'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.13.6/lib/rspec/core/runner.rb:89:in `run'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.13.6/lib/rspec/core/runner.rb:71:in `run'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.13.6/lib/rspec/core/runner.rb:45:in `invoke'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/rspec-core-3.13.6/exe/rspec:4:in `<top (required)>'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/bin/rspec:25:in `load'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/bin/rspec:25:in `<top (required)>'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/3.2.0/bundler/cli/exec.rb:58:in `load'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/3.2.0/bundler/cli/exec.rb:58:in `kernel_load'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/3.2.0/bundler/cli/exec.rb:23:in `run'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/3.2.0/bundler/cli.rb:492:in `exec'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/3.2.0/bundler/cli.rb:34:in `dispatch'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/3.2.0/bundler/cli.rb:28:in `start'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/bundler-2.4.19/libexec/bundle:37:in `block in <top (required)>'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/3.2.0/bundler/friendly_errors.rb:117:in `with_friendly_errors'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/lib/ruby/gems/3.2.0/gems/bundler-2.4.19/libexec/bundle:29:in `<top (required)>'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/bin/bundle:25:in `load'\n/opt/hostedtoolcache/Ruby/3.2.9/x64/bin/bundle:25:in `<main>'",
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rails 8.1: circular dependency on initializer :logstasher

2 participants