Shopify / ruby-lsp

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

Ruby LSP: indexing files: 0% completed hangs forever #2288

Closed argent-smith closed 3 months ago

argent-smith commented 3 months ago

Description

Hi. On my project, I see "Ruby LSP: indexing files: 0% completed" notification and progress spinner — they stay forever

Configuration: VScode 1.91.0 Ruby LSP plugin v0.7.11 ruby-lsp in the project's bundle 0.17.6

andyw8 commented 3 months ago

Hi @argent-smith, can you try running ruby-lsp-doctor in your repo, and see if it hangs.

andyw8 commented 3 months ago

And also check for any errors in the Ruby LSP output panel.

argent-smith commented 3 months ago

can you try running ruby-lsp-doctor in your repo, and see if it hangs

Hi @andyw8, ruby-lsp-doctor doesn't hang

And also check for any errors in the Ruby LSP output panel.

It looks like this: image

argent-smith commented 3 months ago

@andyw8 also, this works fine:

⟩ bundle exec ruby-lsp --time-index
Ruby LSP v0.17.6: Indexing took 9.86661 seconds and generated:
- Module: 14269
- Class: 9314
- Method: 72038
- InstanceVariable: 23228
- Accessor: 9433
- UnresolvedMethodAlias: 3000
- Constant: 7616
- SingletonClass: 3208
- UnresolvedAlias: 434
andyw8 commented 3 months ago

Thanks, please also check here for errors (choose Output, then select Ruby LSP):

Screenshot 2024-07-11 at 12 38 09 PM
argent-smith commented 3 months ago

@andyw8 thank you for the point. I've found and fixed the problem! Thanks to all the contributors for a great tool!

argent-smith commented 3 months ago

Fixed

andyw8 commented 3 months ago

Note: The ruby-lsp-doctor command is now ruby-lsp --doctor (https://github.com/Shopify/ruby-lsp/pull/2310)

thewatts commented 2 months ago

I was having the same

I run ruby-lsp --doctor and get no errors, and my editor nvim just hangs saying that it's at 0%.

Our issue: we needed to upgrade standard.


Note: I attempted to upload screenshots, but for some reason it's not working at the moment.

pablosanderman commented 1 month ago

A senior dev helped me fix it, here's what he did:

First we went to the output tab on vscode, and then selected Ruby LSP in the accordion top right.

We saw that a gem couldn't be installed.

Then we went to Preferences: Open Settings (UI), clicked the extensions tab, then Ruby LSP tab, then we saw that the Bundle Gemfile field waws filled with a path. This should've been empty, but our company configured it to a path, so normal ruby or rails projects couldn't use Ruby LSP.

Image It should be empty

baelter commented 1 week ago

I'm getting a similar issue. Ruby LSP fail to start because it can load a gem required by a rubocop config in a parent folder which shouldn't even be in use since to project has its own. Either way, the gem is installed for the ruby version in use.

They are not installed in the current bundle though.

2024-10-23 11:03:21.224 [info] (rubocop-eightyfourcodes) Finished initializing Ruby LSP!
2024-10-23 11:03:21.473 [info] (rubocop-eightyfourcodes) Error processing initialized: /home/anders/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/feature_loader.rb:46:in `rescue in rescue in load': cannot load such file -- rubocop-gitlab-security (LoadError)
...
    from /home/anders/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/ruby-lsp-0.20.1/lib/ruby_lsp/requests/support/rubocop_runner.rb:86:in `initialize'
baelter commented 1 week ago

Moved my default config to ~/.config/rubocop/config.yml solved it

vinistock commented 1 week ago

They are not installed in the current bundle though.

Bundler doesn't allow you to require any gems that aren't a part of the bundle. It explicitly sets up the $LOAD_PATH to prevent that from happening, so we need all RuboCop extensions to be included in it.

It doesn't matter if they are in a separate Gemfile that you evaluate from the main Gemfile or any other structure, but they need to be a part of the bundle.