sublimelsp / LSP-rust-analyzer

Convenience package for rust-analyzer
MIT License
69 stars 11 forks source link

The rust-analyzer server crashes when I open a Rust file #122

Closed alexbet closed 7 months ago

alexbet commented 7 months ago

Whenever I open a rust file, rust-analyzer is crashing. This is the error that I am getting:

Screenshot 2024-02-07 at 6 14 17 PM

How can I fix this?

rchl commented 7 months ago

Looks like a bug in BracketFlasher package.

alexbet commented 7 months ago

Looks like a bug in BracketFlasher package.

I disabled the Bracket Flasher package, restarted Sublime, but the problem remains.

rchl commented 7 months ago

Follow steps in https://lsp.sublimetext.io/troubleshooting/#self-help-instructions

alexbet commented 7 months ago

I followed everything and everything seems fine, except it errors out. Here is the output from the LSP diagnostics:

Troubleshooting: rust-analyzer

Version

USAGE: rustup run ...

For more information try --help

## Server Configuration
 - command
```json
[
  "rustup", 
  "run", 
  "rust-analyzer"
]

Active view

Project / Workspace

LSP configuration

{
  "clients": {
    "rust-analyzer": {
      "command": [
        "rust-analyzer"
      ], 
      "enabled": true
    }, 
    "serve-d": {
      "command": [
        "/Users/alexbet/.config/serve-d/serve-d"
      ], 
      "enabled": true, 
      "selector": "source.d", 
      "settings": {
        "d.aggressiveUpdate": false, 
        "d.completeNoDupes": true, 
        "d.dcdClientPath": "/Users/alexbet/.config/serve-d/serve-d", 
        "d.dcdServerPath": "/Users/alexbet/.config/serve-d/serve-d", 
        "d.enableAutoComplete": true, 
        "d.manyProjectsAction": "load", 
        "d.servedReleaseChannel": "stable"
      }
    }
  }, 
  "show_inlay_hints": false
}

System PATH

alexbet commented 7 months ago

Just in case someone has this same problem, I figured it out. It seems like there was a problem with permissions of some of the files in the ~/.npm/_cacache folder. When I flushed the NPM cache, everything started working well..

rchl commented 7 months ago

rust-analyzer (or rustup) should have nothing to do with npm. I don't think that was the problem.

The error is pretty clear from the output. You have defined a custom command that doesn't work:

error: error: The following required arguments were not provided:
    <command>...

USAGE:
    rustup run <toolchain> <command>...

For more information try --help

If you run rustup run rust-analyzer in the terminal you will likely get the same error.

rchl commented 7 months ago

Also don't add a rust-analyzer object to LSP global settings. LSP-rust-analyzer has its own settings.

I would suggest:

  1. Remove rust-analyzer from global settings
  2. Edit the command in LSP-rust-analyzer settings to rust-analyzer only.