Skip to content

Commit 2e8ad8e

Browse files
Andy Waitevinistock
andauthored
Add index troubleshooting steps (#2633)
* Add index troubleshooting steps * Apply suggestions from code review Co-authored-by: Vinicius Stock <vinistock@users.noreply.github.com> * Add link to error message * Update test * Fix linting --------- Co-authored-by: Vinicius Stock <vinistock@users.noreply.github.com>
1 parent 4df5ddf commit 2e8ad8e

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

jekyll/troubleshooting.markdown

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ For example, if you configure `BUNDLE_PATH` to point to `vendor/bundle` so that
141141
directory as your project, `bundle install` will automatically pick that up and install them in the right place. But
142142
`gem install` will not as it requires a different setting to achieve it.
143143

144-
You can apply your prefered installed locations for RubyGems by using the `~/.gemrc` file. In that file, you can decide
144+
You can apply your preferred installed locations for RubyGems by using the `~/.gemrc` file. In that file, you can decide
145145
to either install it with `--user-install` or select a specific installation directory with `--install-dir`.
146146

147147
```yaml
@@ -230,6 +230,18 @@ ruby-lsp
230230
Is there any extra information given from booting the server manually? Or does it only fail when booting through the
231231
extension?
232232

233+
## Indexing
234+
235+
When Ruby LSP starts, it attempts to index your code as well as your dependencies as described in [Configuring code indexing](index#configuring-code-indexing).
236+
237+
In rare cases, Ruby LSP will encounter an error which prevents indexing from completing, which will result in incomplete information in the editor.
238+
239+
Firstly, ensure that you are using the latest release of the `ruby-lsp` gem, as the problem may have been already fixed.
240+
241+
To diagnose the particular file(s) causing a problem, run `ruby-lsp-check`. Please log an issue so that we can address it. If the code is not open source then please provide a minimal reproduction.
242+
243+
In the meantime, you can [configure Ruby LSP to ignore a particular gem or file for indexing](index#configuring-code-indexing).
244+
233245
## After troubleshooting
234246

235247
If after troubleshooting the Ruby LSP is still not initializing properly, please report an issue

lib/ruby_lsp/server.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,9 @@ def perform_initial_indexing
969969
false
970970
end
971971
rescue StandardError => error
972-
send_message(Notification.window_show_error("Error while indexing: #{error.message}"))
972+
message = "Error while indexing (see [troubleshooting steps]" \
973+
"(https://shopify.github.io/ruby-lsp/troubleshooting#indexing)): #{error.message}"
974+
send_message(Notification.window_show_error(message))
973975
end
974976

975977
# Indexing produces a high number of short lived object allocations. That might lead to some fragmentation and

test/server_test.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,10 @@ def test_initialized_recovers_from_indexing_failures
186186

187187
notification = @server.pop_response
188188
assert_equal("window/showMessage", notification.method)
189+
expected_message = "Error while indexing (see [troubleshooting steps]" \
190+
"(https://shopify.github.io/ruby-lsp/troubleshooting#indexing)): boom!"
189191
assert_equal(
190-
"Error while indexing: boom!",
192+
expected_message,
191193
T.cast(notification.params, RubyLsp::Interface::ShowMessageParams).message,
192194
)
193195
end

0 commit comments

Comments
 (0)