Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server fails on boot without meaningful error message #2886

Closed
Tossmann opened this issue Nov 20, 2024 · 1 comment · Fixed by Shopify/ruby-lsp-rails#527
Closed

Server fails on boot without meaningful error message #2886

Tossmann opened this issue Nov 20, 2024 · 1 comment · Fixed by Shopify/ruby-lsp-rails#527
Labels
bug Something isn't working vscode This pull request should be included in the VS Code extension's release notes

Comments

@Tossmann
Copy link

Description

Ruby LSP Information

VS Code Version

1.95.3

Ruby LSP Extension Version

0.8.13

Ruby LSP Server Version

0.21.3

Ruby LSP Addons

  • Ruby LSP Rails

Ruby Version

3.3.6

Ruby Version Manager

rbenv

Installed Extensions

Click to expand
  • auto-rename-tag (0.1.10)
  • bust-a-gem (0.1.8)
  • endwise (1.5.1)
  • es7-react-js-snippets (4.4.3)
  • file-icons (1.1.0)
  • gitblame (11.1.1)
  • prettier-vscode (11.0.0)
  • ruby-lsp (0.8.13)
  • vscode-codeowners (1.1.1)
  • vscode-eslint (3.0.10)
  • vscode-fileutils (3.10.3)
  • vscode-jest-runner (0.4.74)
  • vscode-syntax-tree (0.5.1)
  • vscode-tailwindcss (0.12.14)
  • xdt-syntax (0.0.5)

Ruby LSP Settings

Click to expand
Workspace
{
  "formatter": "syntax_tree",
  "linters": [
    "rubocop"
  ],
  "bypassTypechecker": true
}
User
2024-11-20 11:51:26.005 [info] (doctolib) Found rbenv executable at /opt/homebrew/bin
2024-11-20 11:51:26.006 [info] (doctolib) Running command: `/opt/homebrew/bin/rbenv exec ruby -W0 -rjson -e 'STDERR.print("RUBY_LSP_ACTIVATION_SEPARATOR" + { env: ENV.to_h, yjit: !!defined?(RubyVM::YJIT), version: RUBY_VERSION, gemPath: Gem.path }.to_json + "RUBY_LSP_ACTIVATION_SEPARATOR")'` in {redacted_home_path}/projects/doctolib using shell: /opt/homebrew/bin/zsh
2024-11-20 11:51:26.807 [info] (doctolib) Ruby LSP> Skipping custom bundle setup since LSP dependencies are already in {redacted_home_path}/projects/doctolib/Gemfile

2024-11-20 11:51:26.874 [info] (doctolib) Ruby LSP> Running bundle install for the custom bundle. This may take a while...
Ruby LSP> Command: (bundle _2.5.22_ check || bundle _2.5.22_ install) 1>&2

2024-11-20 11:51:27.579 [info] (doctolib) The Gemfile's dependencies are satisfied

2024-11-20 11:51:29.386 [info] (doctolib) Initializing Ruby LSP v0.21.3...
2024-11-20 11:51:29.389 [info] (doctolib) Using formatter specified by user: syntax_tree
2024-11-20 11:51:29.389 [info] (doctolib) Using linters specified by user: rubocop
2024-11-20 11:51:29.389 [info] (doctolib) Detected test library: rails
2024-11-20 11:51:29.389 [info] (doctolib) Finished initializing Ruby LSP!
2024-11-20 11:51:32.721 [info] (doctolib) Activating Ruby LSP Rails add-on v0.3.26
2024-11-20 11:51:32.726 [info] (doctolib) Ruby LSP Rails booting server
2024-11-20 11:51:40.918 [info] (doctolib) [Error - 11:51:40 AM] Ruby LSP Rails failed to initialize server: {redacted_home_path}/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/ruby-lsp-rails-0.3.26/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb:296:in `block in read_response': RubyLsp::Rails::RunnerClient::EmptyMessageError (RubyLsp::Rails::RunnerClient::EmptyMessageError)
	from {redacted_home_path}/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/ruby-lsp-rails-0.3.26/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb:293:in `synchronize'
	from {redacted_home_path}/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/ruby-lsp-rails-0.3.26/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb:293:in `read_response'
	from {redacted_home_path}/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11615/lib/types/private/methods/_methods.rb:279:in `bind_call'
	from {redacted_home_path}/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11615/lib/types/private/methods/_methods.rb:279:in `block in _on_method_added'
	from {redacted_home_path}/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/ruby-lsp-rails-0.3.26/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb:91:in `initialize'
	from {redacted_home_path}/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11615/lib/types/private/methods/_methods.rb:279:in `bind_call'
	from {redacted_home_path}/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11615/lib/types/private/methods/_methods.rb:279:in `block in _on_method_added'
	from {redacted_home_path}/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/ruby-lsp-rails-0.3.26/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb:16:in `new'
	from {redacted_home_path}/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/ruby-lsp-rails-0.3.26/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb:16:in `create_client'
	from {redacted_home_path}/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11615/lib/types/private/methods/_methods.rb:279:in `bind_call'
	from {redacted_home_path}/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11615/lib/types/private/methods/_methods.rb:279:in `block in _on_method_added'
	from {redacted_home_path}/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/ruby-lsp-rails-0.3.26/lib/ruby_lsp/ruby_lsp_rails/addon.rb:41:in `block (3 levels) in initialize'
	from {redacted_home_path}/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/ruby-lsp-rails-0.3.26/lib/ruby_lsp/ruby_lsp_rails/addon.rb:41:in `synchronize'
	from {redacted_home_path}/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/ruby-lsp-rails-0.3.26/lib/ruby_lsp/ruby_lsp_rails/addon.rb:41:in `block (2 levels) in initialize'
	from {redacted_home_path}/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/ruby-lsp-rails-0.3.26/lib/ruby_lsp/ruby_lsp_rails/addon.rb:39:in `synchronize'
	from {redacted_home_path}/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/ruby-lsp-rails-0.3.26/lib/ruby_lsp/ruby_lsp_rails/addon.rb:39:in `block in initialize'

Server dependent features will not be available

Reproduction steps

  1. Open VS Code
  2. Start Ruby-LSP server
  3. Server tries to boot
  4. Fails on boot with error RubyLsp::Rails::RunnerClient::EmptyMessageError

Code snippet or error message

2024-11-20 11:51:26.005 [info] (doctolib) Found rbenv executable at /opt/homebrew/bin
2024-11-20 11:51:26.006 [info] (doctolib) Running command: `/opt/homebrew/bin/rbenv exec ruby -W0 -rjson -e 'STDERR.print("RUBY_LSP_ACTIVATION_SEPARATOR" + { env: ENV.to_h, yjit: !!defined?(RubyVM::YJIT), version: RUBY_VERSION, gemPath: Gem.path }.to_json + "RUBY_LSP_ACTIVATION_SEPARATOR")'` in /Users/phillip.trautmann/projects/doctolib using shell: /opt/homebrew/bin/zsh
2024-11-20 11:51:26.807 [info] (doctolib) Ruby LSP> Skipping custom bundle setup since LSP dependencies are already in /Users/phillip.trautmann/projects/doctolib/Gemfile

2024-11-20 11:51:26.874 [info] (doctolib) Ruby LSP> Running bundle install for the custom bundle. This may take a while...
Ruby LSP> Command: (bundle _2.5.22_ check || bundle _2.5.22_ install) 1>&2

2024-11-20 11:51:27.579 [info] (doctolib) The Gemfile's dependencies are satisfied

2024-11-20 11:51:29.386 [info] (doctolib) Initializing Ruby LSP v0.21.3...
2024-11-20 11:51:29.389 [info] (doctolib) Using formatter specified by user: syntax_tree
2024-11-20 11:51:29.389 [info] (doctolib) Using linters specified by user: rubocop
2024-11-20 11:51:29.389 [info] (doctolib) Detected test library: rails
2024-11-20 11:51:29.389 [info] (doctolib) Finished initializing Ruby LSP!
2024-11-20 11:51:32.721 [info] (doctolib) Activating Ruby LSP Rails add-on v0.3.26
2024-11-20 11:51:32.726 [info] (doctolib) Ruby LSP Rails booting server
2024-11-20 11:51:40.918 [info] (doctolib) [Error - 11:51:40 AM] Ruby LSP Rails failed to initialize server: /Users/phillip.trautmann/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/ruby-lsp-rails-0.3.26/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb:296:in `block in read_response': RubyLsp::Rails::RunnerClient::EmptyMessageError (RubyLsp::Rails::RunnerClient::EmptyMessageError)
	from /Users/phillip.trautmann/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/ruby-lsp-rails-0.3.26/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb:293:in `synchronize'
	from /Users/phillip.trautmann/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/ruby-lsp-rails-0.3.26/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb:293:in `read_response'
	from /Users/phillip.trautmann/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11615/lib/types/private/methods/_methods.rb:279:in `bind_call'
	from /Users/phillip.trautmann/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11615/lib/types/private/methods/_methods.rb:279:in `block in _on_method_added'
	from /Users/phillip.trautmann/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/ruby-lsp-rails-0.3.26/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb:91:in `initialize'
	from /Users/phillip.trautmann/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11615/lib/types/private/methods/_methods.rb:279:in `bind_call'
	from /Users/phillip.trautmann/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11615/lib/types/private/methods/_methods.rb:279:in `block in _on_method_added'
	from /Users/phillip.trautmann/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/ruby-lsp-rails-0.3.26/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb:16:in `new'
	from /Users/phillip.trautmann/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/ruby-lsp-rails-0.3.26/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb:16:in `create_client'
	from /Users/phillip.trautmann/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11615/lib/types/private/methods/_methods.rb:279:in `bind_call'
	from /Users/phillip.trautmann/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/sorbet-runtime-0.5.11615/lib/types/private/methods/_methods.rb:279:in `block in _on_method_added'
	from /Users/phillip.trautmann/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/ruby-lsp-rails-0.3.26/lib/ruby_lsp/ruby_lsp_rails/addon.rb:41:in `block (3 levels) in initialize'
	from /Users/phillip.trautmann/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/ruby-lsp-rails-0.3.26/lib/ruby_lsp/ruby_lsp_rails/addon.rb:41:in `synchronize'
	from /Users/phillip.trautmann/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/ruby-lsp-rails-0.3.26/lib/ruby_lsp/ruby_lsp_rails/addon.rb:41:in `block (2 levels) in initialize'
	from /Users/phillip.trautmann/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/ruby-lsp-rails-0.3.26/lib/ruby_lsp/ruby_lsp_rails/addon.rb:39:in `synchronize'
	from /Users/phillip.trautmann/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/ruby-lsp-rails-0.3.26/lib/ruby_lsp/ruby_lsp_rails/addon.rb:39:in `block in initialize'

Server dependent features will not be available

Running on:

  • MacOS 15.1.1 (24B91)
  • Chip Apple M3 Pro
@Tossmann Tossmann added bug Something isn't working vscode This pull request should be included in the VS Code extension's release notes labels Nov 20, 2024
@vinistock
Copy link
Member

Thank you for the report! This is a known bug for which I'm hoping the fix is Shopify/ruby-lsp-rails#527.

vinistock added a commit to Shopify/ruby-lsp-rails that referenced this issue Nov 22, 2024
Closes Shopify/ruby-lsp#2886

We cannot use blanket rescue statements for the entire server because the behaviour for handling errors is different between requests and notifications.

For requests, we want to return `error: message` instead of the typicaly `result: something`. And for notifications, we cannot return anything, we can only log that an error occurred.

The approach that I took here is to create handlers that we can use both ourselves and in server add-ons, that provide appropriate error handling for requests or notifications.

I also created convenience  methods for returning responses or errors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working vscode This pull request should be included in the VS Code extension's release notes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants