Shopify / ruby-lsp-rails

A Ruby LSP add-on for Rails
https://shopify.github.io/ruby-lsp/rails-add-on
MIT License
565 stars 27 forks source link

Rails addon's server failed to start because Sidekiq tries to connect to non-existing Redis server #449

Closed slhck closed 1 month ago

slhck commented 1 month ago

Description

Ruby LSP Information

Please run Collect Ruby LSP Information for Issue Reporting from VS Code's command palette and paste the result here

I have no such command!

Image

I am using VS Code 1.91.1 with the v0.7.14 Ruby LSP extension.

The problem is that it somehow tries to boot Sidekiq, which again tries to connect to a Redis server that does not exist (since my actual Redis server runs in Docker, and the Rails app does, too).

How could I bypass this?

Reproduction steps

  1. Start the Ruby LSP using a certain editor
  2. Open a Ruby file
  3. Check out the logs

Code snippet or error message

2024-09-05 09:54:41.912 [info] (example) Checking if chruby is available on the path with command: /bin/zsh -i -c 'chruby --version'
2024-09-05 09:54:48.455 [info] (example) Checking if rbenv is available on the path with command: /bin/zsh -i -c 'rbenv --version'
2024-09-05 09:54:51.444 [info] (example) Checking if rvm is available on the path with command: /bin/zsh -i -c 'rvm --version'
2024-09-05 09:54:52.635 [info] (example) Checking if asdf is available on the path with command: /bin/zsh -i -c 'asdf --version'
2024-09-05 09:54:55.815 [info] (example) Discovered version manager none
2024-09-05 09:54:55.815 [info] (example) Running command: `ruby -W0 -rjson -e 'STDERR.print({ env: ENV.to_h, yjit: !!defined?(RubyVM::YJIT), version: RUBY_VERSION }.to_json)'` in /Users/werner/Documents/Projects/example using shell: /opt/homebrew/bin/zsh
2024-09-05 09:55:36.112 [info] (example) Ruby LSP> Skipping custom bundle setup since /Users/werner/Documents/Projects/example/.ruby-lsp/Gemfile.lock already exists and is up to date

2024-09-05 09:55:36.131 [info] (example) Ruby LSP> Running bundle install for the custom bundle. This may take a while...
Ruby LSP> Command: ((bundle check && bundle update ruby-lsp debug ruby-lsp-rails) || bundle install) 1>&2

2024-09-05 09:55:36.519 [info] (example) The Gemfile's dependencies are satisfied

2024-09-05 09:55:38.624 [info] (example) Fetching gem metadata from https://rubygems.org/
2024-09-05 09:55:38.626 [info] (example) .
2024-09-05 09:55:38.923 [info] (example) .
2024-09-05 09:55:38.981 [info] (example) .
2024-09-05 09:55:39.020 [info] (example) .
2024-09-05 09:55:39.074 [info] (example) .
2024-09-05 09:55:39.084 [info] (example) .
2024-09-05 09:55:39.091 [info] (example) .
2024-09-05 09:55:39.092 [info] (example) .
2024-09-05 09:55:39.946 [info] (example) 

2024-09-05 09:55:40.128 [info] (example) Resolving dependencies...

2024-09-05 09:55:40.942 [info] (example) Using prism 1.0.0 (was 0.30.0)

2024-09-05 09:55:40.951 [info] (example) Fetching logger 1.6.1 (was 1.6.0)

2024-09-05 09:55:40.954 [info] (example) Fetching sorbet-runtime 0.5.11554 (was 0.5.11547)

2024-09-05 09:55:41.149 [info] (example) Installing logger 1.6.1 (was 1.6.0)

2024-09-05 09:55:41.155 [info] (example) Installing sorbet-runtime 0.5.11554 (was 0.5.11547)

2024-09-05 09:55:41.342 [info] (example) Using ruby-lsp 0.17.17 (was 0.17.16)

2024-09-05 09:55:41.357 [info] (example) Bundler attempted to update debug but its version stayed the same
Bundler attempted to update ruby-lsp-rails but its version stayed the same
Bundle updated!

2024-09-05 09:55:41.358 [info] (example) 2 installed gems you directly depend on are looking for funding.
  Run `bundle fund` for details

2024-09-05 09:55:44.460 [info] (example) Initializing Ruby LSP v0.17.17...
2024-09-05 09:55:44.503 [info] (example) Using formatter specified by user: rubocop
2024-09-05 09:55:44.504 [info] (example) Auto detected linters: rubocop
2024-09-05 09:55:44.504 [info] (example) Detected test library: rspec
2024-09-05 09:55:44.504 [info] (example) Finished initializing Ruby LSP!
2024-09-05 09:55:44.531 [info] (example) Activating Ruby LSP Rails addon v0.3.13

2024-09-05 09:55:44.542 [info] (example) Ruby LSP Rails booting server

2024-09-05 09:55:50.181 [info] (example) Ruby LSP Rails is retrying initialize (1)

2024-09-05 09:55:50.182 [info] (example) Ruby LSP Rails failed to initialize server: /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/socket.rb:1217:in `__connect_nonblock': Connection refused - connect(2) for 127.0.0.1:6379 (redis://localhost:6379) (RedisClient::CannotConnectError)
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/socket.rb:1217:in `connect_nonblock'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/socket.rb:60:in `connect_internal'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/socket.rb:141:in `connect'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/socket.rb:645:in `block in tcp'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/socket.rb:231:in `each'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/socket.rb:231:in `foreach'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/socket.rb:635:in `tcp'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/redis-client-0.22.2/lib/redis_client/ruby_connection.rb:119:in `connect'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/redis-client-0.22.2/lib/redis_client/ruby_connection.rb:51:in `initialize'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/redis-client-0.22.2/lib/redis_client.rb:746:in `new'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/redis-client-0.22.2/lib/redis_client.rb:746:in `block in connect'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/redis-client-0.22.2/lib/redis_client/middlewares.rb:12:in `connect'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/redis-client-0.22.2/lib/redis_client.rb:745:in `connect'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/redis-client-0.22.2/lib/redis_client.rb:732:in `raw_connection'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/redis-client-0.22.2/lib/redis_client.rb:697:in `ensure_connected'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/redis-client-0.22.2/lib/redis_client.rb:277:in `call'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-7.3.0/lib/sidekiq/redis_client_adapter.rb:36:in `block (2 levels) in <module:CompatMethods>'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-7.3.0/lib/sidekiq/api.rb:622:in `block in size'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-7.3.0/lib/sidekiq/config.rb:167:in `block in redis'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/connection_pool-2.4.1/lib/connection_pool.rb:110:in `block (2 levels) in with'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/connection_pool-2.4.1/lib/connection_pool.rb:109:in `handle_interrupt'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/connection_pool-2.4.1/lib/connection_pool.rb:109:in `block in with'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/connection_pool-2.4.1/lib/connection_pool.rb:106:in `handle_interrupt'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/connection_pool-2.4.1/lib/connection_pool.rb:106:in `with'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-7.3.0/lib/sidekiq/config.rb:164:in `redis'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-7.3.0/lib/sidekiq.rb:74:in `redis'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-7.3.0/lib/sidekiq/api.rb:622:in `size'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-7.3.0/lib/sidekiq/api.rb:617:in `initialize'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-7.3.0/lib/sidekiq/api.rb:776:in `initialize'
    from /Users/werner/Documents/Projects/example/config/initializers/sidekiq.rb:93:in `new'
    from /Users/werner/Documents/Projects/example/config/initializers/sidekiq.rb:93:in `<main>'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/engine.rb:690:in `load'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/engine.rb:690:in `block in load_config_initializer'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.1.3.4/lib/active_support/notifications.rb:208:in `instrument'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/engine.rb:689:in `load_config_initializer'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/engine.rb:643:in `block (2 levels) in <class:Engine>'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/engine.rb:642:in `each'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/engine.rb:642:in `block in <class:Engine>'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/initializable.rb:32:in `instance_exec'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/initializable.rb:32:in `run'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/initializable.rb:61:in `block in run_initializers'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:228:in `block in tsort_each'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:431:in `each_strongly_connected_component_from'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/initializable.rb:50:in `each'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/initializable.rb:50:in `tsort_each_child'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:415:in `call'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:415:in `each_strongly_connected_component_from'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:349:in `block in each_strongly_connected_component'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:347:in `each'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:347:in `call'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:347:in `each_strongly_connected_component'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:226:in `tsort_each'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:205:in `tsort_each'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/initializable.rb:60:in `run_initializers'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/application.rb:426:in `initialize!'
    from /Users/werner/Documents/Projects/example/config/environment.rb:5:in `<main>'
    from <internal:/Users/werner/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
    from <internal:/Users/werner/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bootsnap-1.18.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/zeitwerk-2.6.16/lib/zeitwerk/kernel.rb:34:in `require'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/application.rb:402:in `require_environment!'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/command/actions.rb:20:in `boot_application!'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/
2024-09-05 09:55:50.182 [info] (example) gems/railties-7.1.3.4/lib/rails/commands/runner/runner_command.rb:28:in `perform'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.3.1/lib/thor/command.rb:28:in `run'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.3.1/lib/thor/invocation.rb:127:in `invoke_command'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/command/base.rb:178:in `invoke_command'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.3.1/lib/thor.rb:527:in `dispatch'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/command/base.rb:73:in `perform'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/command.rb:71:in `block in invoke'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/command.rb:149:in `with_argv'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/command.rb:69:in `invoke'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/commands.rb:18:in `<main>'
    from <internal:/Users/werner/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
    from <internal:/Users/werner/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bootsnap-1.18.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
    from bin/rails:4:in `<main>'
/Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/socket.rb:1217:in `__connect_nonblock': Connection refused - connect(2) for 127.0.0.1:6379 (Errno::ECONNREFUSED)
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/socket.rb:1217:in `connect_nonblock'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/socket.rb:60:in `connect_internal'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/socket.rb:141:in `connect'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/socket.rb:645:in `block in tcp'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/socket.rb:231:in `each'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/socket.rb:231:in `foreach'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/socket.rb:635:in `tcp'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/redis-client-0.22.2/lib/redis_client/ruby_connection.rb:119:in `connect'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/redis-client-0.22.2/lib/redis_client/ruby_connection.rb:51:in `initialize'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/redis-client-0.22.2/lib/redis_client.rb:746:in `new'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/redis-client-0.22.2/lib/redis_client.rb:746:in `block in connect'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/redis-client-0.22.2/lib/redis_client/middlewares.rb:12:in `connect'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/redis-client-0.22.2/lib/redis_client.rb:745:in `connect'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/redis-client-0.22.2/lib/redis_client.rb:732:in `raw_connection'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/redis-client-0.22.2/lib/redis_client.rb:697:in `ensure_connected'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/redis-client-0.22.2/lib/redis_client.rb:277:in `call'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-7.3.0/lib/sidekiq/redis_client_adapter.rb:36:in `block (2 levels) in <module:CompatMethods>'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-7.3.0/lib/sidekiq/api.rb:622:in `block in size'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-7.3.0/lib/sidekiq/config.rb:167:in `block in redis'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/connection_pool-2.4.1/lib/connection_pool.rb:110:in `block (2 levels) in with'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/connection_pool-2.4.1/lib/connection_pool.rb:109:in `handle_interrupt'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/connection_pool-2.4.1/lib/connection_pool.rb:109:in `block in with'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/connection_pool-2.4.1/lib/connection_pool.rb:106:in `handle_interrupt'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/connection_pool-2.4.1/lib/connection_pool.rb:106:in `with'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-7.3.0/lib/sidekiq/config.rb:164:in `redis'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-7.3.0/lib/sidekiq.rb:74:in `redis'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-7.3.0/lib/sidekiq/api.rb:622:in `size'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-7.3.0/lib/sidekiq/api.rb:617:in `initialize'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-7.3.0/lib/sidekiq/api.rb:776:in `initialize'
    from /Users/werner/Documents/Projects/example/config/initializers/sidekiq.rb:93:in `new'
    from /Users/werner/Documents/Projects/example/config/initializers/sidekiq.rb:93:in `<main>'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/engine.rb:690:in `load'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/engine.rb:690:in `block in load_config_initializer'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.1.3.4/lib/active_support/notifications.rb:208:in `instrument'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/engine.rb:689:in `load_config_initializer'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/engine.rb:643:in `block (2 levels) in <class:Engine>'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/engine.rb:642:in `each'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/engine.rb:642:in `block in <class:Engine>'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/initializable.rb:32:in `instance_exec'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/initializable.rb:32:in `run'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/initializable.rb:61:in `block in run_initializers'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:228:in `block in tsort_each'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:431:in `each_strongly_connected_component_from'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/initializable.rb:50:in `each'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/initializable.rb:50:in `tsort_each_child'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:415:in `call'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:415:in `each_strongly_connected_component_from'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:349:in `block in each_strongly_connected_component'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:347:in `each'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:347:in `call'
    f
2024-09-05 09:55:50.182 [info] (example) rom /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:347:in `each_strongly_connected_component'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:226:in `tsort_each'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:205:in `tsort_each'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/initializable.rb:60:in `run_initializers'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/application.rb:426:in `initialize!'
    from /Users/werner/Documents/Projects/example/config/environment.rb:5:in `<main>'
    from <internal:/Users/werner/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
    from <internal:/Users/werner/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bootsnap-1.18.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/zeitwerk-2.6.16/lib/zeitwerk/kernel.rb:34:in `require'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/application.rb:402:in `require_environment!'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/command/actions.rb:20:in `boot_application!'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/commands/runner/runner_command.rb:28:in `perform'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.3.1/lib/thor/command.rb:28:in `run'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.3.1/lib/thor/invocation.rb:127:in `invoke_command'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/command/base.rb:178:in `invoke_command'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.3.1/lib/thor.rb:527:in `dispatch'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/command/base.rb:73:in `perform'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/command.rb:71:in `block in invoke'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/command.rb:149:in `with_argv'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/command.rb:69:in `invoke'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3.4/lib/rails/commands.rb:18:in `<main>'
    from <internal:/Users/werner/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
    from <internal:/Users/werner/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
    from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bootsnap-1.18.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
    from bin/rails:4:in `<main>'

/Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/ruby-lsp-rails-0.3.13/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb:93:in `rescue in initialize'
/Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/ruby-lsp-rails-0.3.13/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb:43:in `initialize'
/Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sorbet-runtime-0.5.11554/lib/types/private/methods/_methods.rb:279:in `bind_call'
/Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sorbet-runtime-0.5.11554/lib/types/private/methods/_methods.rb:279:in `block in _on_method_added'
/Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/ruby-lsp-rails-0.3.13/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb:16:in `new'
/Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/ruby-lsp-rails-0.3.13/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb:16:in `create_client'
/Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sorbet-runtime-0.5.11554/lib/types/private/methods/_methods.rb:279:in `bind_call'
/Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sorbet-runtime-0.5.11554/lib/types/private/methods/_methods.rb:279:in `block in _on_method_added'
/Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/ruby-lsp-rails-0.3.13/lib/ruby_lsp/ruby_lsp_rails/addon.rb:37:in `block in activate'

2024-09-05 09:55:50.183 [info] (example) Server dependent features will not be available

2024-09-05 09:56:01.826 [info] (example) Running command: `rbenv exec ruby -W0 -rjson -e 'STDERR.print({env: ENV.to_h,yjit:!!defined?(RubyVM::YJIT),version:RUBY_VERSION}.to_json)'` in /Users/werner/Documents/Projects/example using shell: /opt/homebrew/bin/zsh
2024-09-05 09:56:02.437 [info] (example) Running command: `rbenv exec ruby -W0 -rjson -e 'STDERR.print({env: ENV.to_h,yjit:!!defined?(RubyVM::YJIT),version:RUBY_VERSION}.to_json)'` in /Users/werner/Documents/Projects/example using shell: /opt/homebrew/bin/zsh
2024-09-05 09:56:02.516 [info] (example) [Error - 9:56:02 AM] Server process exited with code 0.
st0012 commented 1 month ago

I am using VS Code 1.91.1 with the v0.7.14 Ruby LSP extension.

Is there any reason not to use the latest extension? Can you update the extension and paste the relevant information here?

Normally, even when an addon failed to activate, the Ruby LSP process would still be running. Does the status panel show it's running?

Image

If it does, then the issue is purely related to ruby-lsp-rails. If it doesn't, then it means we have a separate issue on the Ruby LSP side too, and the additional information from the command will help a lot 🙂

slhck commented 1 month ago

I am using VS Code 1.91.1 with the v0.7.14 Ruby LSP extension.

Is there any reason not to use the latest extension? Can you update the extension and paste the relevant information here?

I didn't get any update notification for it, now I am on v0.7.19! Thanks for catching that.

Normally, even when an addon failed to activate, the Ruby LSP process would still be running. Does the status panel show it's running?

It's running indeed:

Image

Although it says v0.7.17, despite the extension being v0.7.19 …

If it does, then the issue is purely related to ruby-lsp-rails. If it doesn't, then it means we have a separate issue on the Ruby LSP side too, and the additional information from the command will help a lot 🙂

I understand this to be an issue in https://github.com/Shopify/ruby-lsp-rails, so I will close accordingly.

st0012 commented 1 month ago

@slhck Sorry that I wasn't clear, if it's a ruby-lsp-rails issue I can simply transfer it there 😅 Thanks for confirming 🙂

slhck commented 1 month ago

Oh, alright, thanks!

I think I have to clarify that I was more confused about the fact that it's even trying to boot Sidekiq in the first place. I could get everything working once I set up the Redis server, but I didn't expect the LSP to require that for code analysis. Or is it merely triggering the start of the Sidekiq worker when reading its configurarion file?

st0012 commented 1 month ago

Ruby LSP Rails starts a Rails application process in background to collect runtime information as explained here.

From the backtrace:

from /Users/werner/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sidekiq-7.3.0/lib/sidekiq/api.rb:776:in `initialize'
from /Users/werner/Documents/Projects/example/config/initializers/sidekiq.rb:93:in `new'
from /Users/werner/Documents/Projects/example/config/initializers/sidekiq.rb:93:in `<main>'

It looks like your app is trying to initialize ScheduledSet and that causes Sidekiq to make a Redis connection EVERY time your app is loaded, which includes running many rake tasks, Rails runner, Rails console...etc. So maybe you'd want to wrap it inside a callback like:

  # config/initializers/sidekiq.rb
  Sidekiq.configure_server do |config|
    config.on(:startup) do
      # something that needs Sidekiq::ScheduledSet.new
    end
  end

And then that code will only be performed when the apps is loaded by Sidekiq.

slhck commented 1 month ago

Thanks for the great explanation! So it runs any initializer as a normal Rails app would. I can work around this. I wonder if we could address this somehow in the documentation such that unexpected errors like this can be discovered better? Then again, maybe this issue is enough, and this is just an edge case.

I'll close this for now.