rust-analyzer/docs/book/src/troubleshooting.md
Wilfred Hughes deda58e8f1 manual: Convert to mdbook
Split manual.adoc into markdown files, one for each chapter.

For the parts of the manual that are generated from source code doc
comments, update the comments to use markdown syntax and update the
code generators to write to `generated.md` files.

For the weekly release, stop copying the .adoc files to the
`rust-analyzer/rust-analyzer.github.io` at release time. Instead,
we'll sync the manual hourly from this repository.

See https://github.com/rust-analyzer/rust-analyzer.github.io/pull/226
for the sync. This PR should be merged first, and that PR needs to be
merged before the next weekly release.

This change is based on #15795, but rebased and updated. I've also
manually checked each page for markdown syntax issues and fixed any I
encountered.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
Co-authored-by: Josh Rotenberg <joshrotenberg@gmail.com>
2025-01-24 13:23:22 -08:00

2.2 KiB
Raw Blame History

Troubleshooting

Start with looking at the rust-analyzer version. Try rust-analyzer: Show RA Version in VS Code (using Command Palette feature typically activated by Ctrl+Shift+P) or rust-analyzer --version in the command line. If the date is more than a week ago, its better to update rust-analyzer version.

The next thing to check would be panic messages in rust-analyzers log. Log messages are printed to stderr, in VS Code you can see them in the Output > Rust Analyzer Language Server tab of the panel. To see more logs, set the RA_LOG=info environment variable, this can be done either by setting the environment variable manually or by using rust-analyzer.server.extraEnv, note that both of these approaches require the server to be restarted.

To fully capture LSP messages between the editor and the server, run the rust-analyzer: Toggle LSP Logs command and check Output > Rust Analyzer Language Server Trace.

The root cause for many "nothing works" problems is that rust-analyzer fails to understand the project structure. To debug that, first note the rust-analyzer section in the status bar. If it has an error icon and red, thats the problem (hover will have somewhat helpful error message). rust-analyzer: Status prints dependency information for the current file. Finally, RA_LOG=project_model=debug enables verbose logs during project loading.

If rust-analyzer outright crashes, try running rust-analyzer analysis-stats /path/to/project/directory/ on the command line. This command type checks the whole project in batch mode bypassing LSP machinery.

When filing issues, it is useful (but not necessary) to try to minimize examples. An ideal bug reproduction looks like this:

$ git clone https://github.com/username/repo.git && cd repo && git switch --detach commit-hash
$ rust-analyzer --version
rust-analyzer dd12184e4 2021-05-08 dev
$ rust-analyzer analysis-stats .
💀 💀 💀

It is especially useful when the repo doesnt use external crates or the standard library.

If you want to go as far as to modify the source code to debug the problem, be sure to take a look at the dev docs!