Shopify / ruby-lsp

An opinionated language server for Ruby
https://shopify.github.io/ruby-lsp/
MIT License
1.33k stars 118 forks source link

Failed to initialize server (cannot load such file -- sorbet-runtime) #1959

Closed j15e closed 3 weeks ago

j15e commented 3 weeks ago

Description

I get server startup error cannot load such file -- sorbet-runtime from time to time using Ruby-LSP inside VS Code.

Reproduction steps

I am not certain of the steps to reproduce as this appear to happen at random, there must be specific steps, I just haven't found them yet.

The problem both happen with v0.16.4 and pre-release version (and asdf as the version manager with Ruby 3.1.4).

We do not use Sorbet in our project, so it could be related to that.

Could it be related to the Spring process?

Code snippet or error message


2024-04-22 09:18:27.821 [info] (project) Ruby LSP> Running bundle install for the custom bundle. This may take a while...
Ruby LSP> Command: (bundle check || bundle install) 1>&2

2024-04-22 09:18:28.096 [info] (project) The Gemfile's dependencies are satisfied

2024-04-22 09:18:29.718 [info] (project) Initializing Ruby LSP v0.16.4...

2024-04-22 09:18:29.770 [info] (project) Finished initializing Ruby LSP!

2024-04-22 09:18:29.794 [info] (project) Activating Ruby LSP Rails addon v0.16.4

2024-04-22 09:18:29.802 [info] (project) Ruby LSP Rails booting server

2024-04-22 09:18:30.429 [info] (project) Ruby LSP Rails failed to initialize server: Running via Spring preloader in process 88847
/Users/jean-philippe.doyle/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in `require': cannot load such file -- sorbet-runtime (LoadError)
    from /Users/jean-philippe.doyle/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in `require'
    from /Users/jean-philippe.doyle/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/zeitwerk-2.6.12/lib/zeitwerk/kernel.rb:38:in `require'
    from /Users/jean-philippe.doyle/.gem/ruby/3.1.0/gems/ruby-lsp-rails-0.3.5/lib/ruby_lsp/ruby_lsp_rails/server.rb:4:in `<main>'
    from /Users/jean-philippe.doyle/.gem/ruby/3.1.0/bundler/gems/rails-1540cb381b4c/railties/lib/rails/commands/runner/runner_command.rb:42:in `load'
    from /Users/jean-philippe.doyle/.gem/ruby/3.1.0/bundler/gems/rails-1540cb381b4c/railties/lib/rails/commands/runner/runner_command.rb:42:in `perform'
    from /Users/jean-philippe.doyle/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/thor-1.3.0/lib/thor/command.rb:28:in `run'
    from /Users/jean-philippe.doyle/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/thor-1.3.0/lib/thor/invocation.rb:127:in `invoke_command'
    from /Users/jean-philippe.doyle/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/thor-1.3.0/lib/thor.rb:527:in `dispatch'
    from /Users/jean-philippe.doyle/.gem/ruby/3.1.0/bundler/gems/rails-1540cb381b4c/railties/lib/rails/command/base.rb:69:in `perform'
    from /Users/jean-philippe.doyle/.gem/ruby/3.1.0/bundler/gems/rails-1540cb381b4c/railties/lib/rails/command.rb:48:in `invoke'
    from /Users/jean-philippe.doyle/.gem/ruby/3.1.0/bundler/gems/rails-1540cb381b4c/railties/lib/rails/commands.rb:18:in `<main>'
    from /Users/jean-philippe.doyle/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
    from /Users/jean-philippe.doyle/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
    from /Users/jean-philippe.doyle/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/zeitwerk-2.6.12/lib/zeitwerk/kernel.rb:38:in `require'
    from /Users/jean-philippe.doyle/repos/project/bin/rails:5:in `<main>'
    from /Users/jean-philippe.doyle/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/spring-4.1.1/lib/spring/commands/rails.rb:6:in `load'
    from /Users/jean-philippe.doyle/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/spring-4.1.1/lib/spring/commands/rails.rb:6:in `call'
    from /Users/jean-philippe.doyle/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/spring-4.1.1/lib/spring/commands/rails.rb:51:in `call'
    from /Users/jean-philippe.doyle/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/spring-4.1.1/lib/spring/command_wrapper.rb:38:in `call'
    from /Users/jean-philippe.doyle/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/spring-4.1.1/lib/spring/application.rb:221:in `block in serve'
    from /Users/jean-philippe.doyle/.gem/ruby/3.1.0/bundler/gems/rails-1540cb381b4c/activesupport/lib/active_support/fork_tracker.rb:10:in `block in fork'
    from /Users/jean-philippe.doyle/.gem/ruby/3.1.0/bundler/gems/rails-1540cb381b4c/activesupport/lib/active_support/fork_tracker.rb:10:in `block in fork'
    from /Users/jean-philippe.doyle/.gem/ruby/3.1.0/bundler/gems/rails-1540cb381b4c/activesupport/lib/active_support/fork_tracker.rb:8:in `fork'
    from /Users/jean-philippe.doyle/.gem/ruby/3.1.0/bundler/gems/rails-1540cb381b4c/activesupport/lib/active_support/fork_tracker.rb:8:in `fork'
    from /Users/jean-philippe.doyle/.gem/ruby/3.1.0/bundler/gems/rails-1540cb381b4c/activesupport/lib/active_support/fork_tracker.rb:27:in `fork'
    from /Users/jean-philippe.doyle/.gem/ruby/3.1.0/bundler/gems/rails-1540cb381b4c/activesupport/lib/active_support/fork_tracker.rb:8:in `fork'
    from /Users/jean-philippe.doyle/.gem/ruby/3.1.0/bundler/gems/rails-1540cb381b4c/activesupport/lib/active_support/fork_tracker.rb:27:in `fork'
    from /Users/jean-philippe.doyle/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/spring-4.1.1/lib/spring/application.rb:185:in `serve'
    from /Users/jean-philippe.doyle/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/spring-4.1.1/lib/spring/application.rb:148:in `block in run'
    from /Users/jean-philippe.doyle/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/spring-4.1.1/lib/spring/application.rb:142:in `loop'
    from /Users/jean-philippe.doyle/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/spring-4.1.1/lib/spring/application.rb:142:in `run'
    from /Users/jean-philippe.doyle/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/spring-4.1.1/lib/spring/application/boot.rb:19:in `<top (required)>'
    from <internal:/Users/jean-philippe.doyle/.asdf/installs/ruby/3.1.4/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from <internal:/Users/jean-philippe.doyle/.asdf/installs/ruby/3.1.4/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from -e:1:in `<main>'
j15e commented 3 weeks ago

Ah, I think this is actually a problem with the rails extension (already documented in https://github.com/Shopify/ruby-lsp-rails/issues/336)

andyw8 commented 3 weeks ago

Thanks, this helps us to prioritize the fix as so far we hadn't had any other reports.