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

Ruby LSP Rails failed to initialize server #452

Closed
reppiee opened this issue Sep 16, 2024 · 6 comments
Closed

Ruby LSP Rails failed to initialize server #452

reppiee opened this issue Sep 16, 2024 · 6 comments

Comments

@reppiee
Copy link

reppiee commented Sep 16, 2024

I've installed ruby-lsp and successfully using that using the Ruby LSP VSCode extension, however Ruby LSP Rails fails to initialize its server with the following error:

2024-09-16 11:47:06.554 [info] (core) Ruby LSP Rails failed to initialize server: 
/Users/steven/.asdf/installs/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/ruby-lsp-rails-0.3.11/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb:94:in `rescue in initialize'
/Users/steven/.asdf/installs/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/ruby-lsp-rails-0.3.11/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb:43:in `initialize'
/Users/steven/.asdf/installs/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/sorbet-runtime-0.5.11422/lib/types/private/methods/_methods.rb:279:in `bind_call'
/Users/steven/.asdf/installs/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/sorbet-runtime-0.5.11422/lib/types/private/methods/_methods.rb:279:in `block in _on_method_added'
/Users/steven/.asdf/installs/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/ruby-lsp-rails-0.3.11/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb:16:in `new'
/Users/steven/.asdf/installs/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/ruby-lsp-rails-0.3.11/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb:16:in `create_client'
/Users/steven/.asdf/installs/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/sorbet-runtime-0.5.11422/lib/types/private/methods/_methods.rb:279:in `bind_call'
/Users/steven/.asdf/installs/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/sorbet-runtime-0.5.11422/lib/types/private/methods/_methods.rb:279:in `block in _on_method_added'
/Users/steven/.asdf/installs/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/ruby-lsp-rails-0.3.11/lib/ruby_lsp/ruby_lsp_rails/addon.rb:36:in `block in activate'
Server dependent features will not be available

Any ideas on why or what I could do to fix it?

@vinistock
Copy link
Member

Thank you for the bug report! The backtrace seems to be incomplete for whatever reason, so it's hard to tell what's going on without the error message.

I do see that you're on v0.3.11 of ruby-lsp-rails, which is not the latest. Can you please try upgrading? Alternatively, do you see the error message printed anywhere?

@reppiee
Copy link
Author

reppiee commented Sep 18, 2024

Yeah the incompleteness is also what's throwing me off - I have no idea where to look for the problem.

I've tried updating to the latest, but still getting the same error:

2024-09-18 13:31:30.557 [info] (core) Finished initializing Ruby LSP!
2024-09-18 13:31:30.585 [info] (core) Activating Ruby LSP Rails addon v0.3.15

2024-09-18 13:31:30.591 [info] (core) Ruby LSP Rails booting server

2024-09-18 13:31:31.654 [info] (core) Ruby LSP Rails is retrying initialize (1)
Ruby LSP Rails failed to initialize server: 
/Users/steven/.asdf/installs/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/ruby-lsp-rails-0.3.15/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb:96:in `rescue in initialize'
/Users/steven/.asdf/installs/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/ruby-lsp-rails-0.3.15/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb:43:in `initialize'
/Users/steven/.asdf/installs/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/sorbet-runtime-0.5.11422/lib/types/private/methods/_methods.rb:279:in `bind_call'
/Users/steven/.asdf/installs/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/sorbet-runtime-0.5.11422/lib/types/private/methods/_methods.rb:279:in `block in _on_method_added'
/Users/steven/.asdf/installs/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/ruby-lsp-rails-0.3.15/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb:16:in `new'
/Users/steven/.asdf/installs/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/ruby-lsp-rails-0.3.15/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb:16:in `create_client'
/Users/steven/.asdf/installs/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/sorbet-runtime-0.5.11422/lib/types/private/methods/_methods.rb:279:in `bind_call'
/Users/steven/.asdf/installs/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/sorbet-runtime-0.5.11422/lib/types/private/methods/_methods.rb:279:in `block in _on_method_added'
/Users/steven/.asdf/installs/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/ruby-lsp-rails-0.3.15/lib/ruby_lsp/ruby_lsp_rails/addon.rb:41:in `block in activate'
Server dependent features will not be available

@vinistock
Copy link
Member

Yeah, it's really hard to tell without the full trace (and I'm not sure why it's only printed the partial trace).

If you have time, trying to launch the runtime server manually might help us figure out what's wrong. Essentially, you just need to execute the server with rails runner, which should hopefully break in the same way and print the full trace:

  1. Figure out the full path to the server.rb file for your ruby-lsp-rails installation: BUNDLE_GEMFILE=.ruby-lsp/Gemfile bundle show ruby-lsp-rails (prints the path to the gem installation)
  2. After you have the path to the gem root, you are looking for this file
  3. With the full path in hand, spawn the server using Rails runner. This is what we do in the addon
bin/rails runner /path/to/gems/ruby-lsp-rails-0.3.15/lib/ruby_lsp/ruby_lsp_rails/server.rb start

@reppiee
Copy link
Author

reppiee commented Sep 27, 2024

Hi, sorry it took a while to get back to this!

I've tried your suggestions:

  1. Locating the full path
❯ BUNDLE_GEMFILE=.ruby-lsp/Gemfile bundle show ruby-lsp-rails
/Users/steven/.asdf/installs/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/ruby-lsp-rails-0.3.15
  1. Use rails runner
❯ bin/rails runner "/Users/steven/.asdf/installs/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/ruby-lsp-rails-0.3.15" start
Please specify a valid ruby command or the path of a script to run.
Run 'rails runner -h' for help.

/usr/local/bundle/gems/railties-6.1.7.8/lib/rails/commands/runner/runner_command.rb:45: unknown regexp options - tv
/Users/steven/.asdf/installs/ruby/3.2.5/li...
      ^~~~~~~
/usr/local/bundle/gems/railties-6.1.7.8/lib/rails/commands/runner/runner_command.rb:45: syntax error, unexpected '.'
/Users/steven/.asdf/installs/ruby/3.2.5/lib/...
              ^

Probably doing something wrong, since I don't expect that to be the actual error. Posting here just in case it does explain something - but will revisit next week to try and actually run it to get logging/stacktrace of error.

@vinistock
Copy link
Member

You need to specify the path to the server.rb file, so it's almost there. It should be

bin/rails runner "/Users/steven/.asdf/installs/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/ruby-lsp-rails-0.3.15/lib/ruby_lsp/ruby_lsp_rails/server.rb" start

@reppiee
Copy link
Author

reppiee commented Oct 15, 2024

Sorry for not coming back to this - a colleague of mine went down the rabbithole and figured out that it was not starting properly due to customised rails bin stubs that we use.

Apologies and thanks for the help!

@reppiee reppiee closed this as completed Oct 15, 2024
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

No branches or pull requests

2 participants