zed icon indicating copy to clipboard operation
zed copied to clipboard

Rust Analyzer fails to run, Potential bug in rust-analyzer-2024-10-14

Open RationalAsh opened this issue 1 year ago • 13 comments

Check for existing issues

  • [X] Completed

Describe the bug / provide steps to reproduce it

When starting Zed, rust analyzer fails to start with the error message as in the screenshot below. Screenshot 2024-10-15 at 5 30 07 PM

The error message is

Language server error: rust-analyzer

failed to spawn command. path: "/Users/ashwin/Library/Application Support/Zed/languages/rust-analyzer/rust-analyzer-2024-10-14", working directory: "/Users/ashwin/GitHub/rust/gd32f4_rs_test", args: []
-- stderr--

I tried to debug what was going on a little - I thought that perhaps the issue was with rust analyzer itself. So I found out that the rust "/Users/ashwin/Library/Application Support/Zed/languages/rust-analyzer/" folder had a previous version of the binary in it. I added the following in .zed/settings.json to switch to rust-analyzer-2024-10-07.

{
  "lsp": {
    "rust-analyzer": {
      "binary": {
        "path": "/Users/ashwin/Library/Application Support/Zed/languages/rust-analyzer/rust-analyzer-2024-10-07",
        "arguments": ["--no-log-buffering"]
      }
    }
  }
}

And things seem to be working. Perhaps there is a bug in rust-analyzer-2024-10-14?

Environment

Zed: v0.156.2 (Zed) OS: macOS 14.7.0 Memory: 16 GiB Architecture: x86_64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your Zed.log file to this issue.

Zed.log

RationalAsh avatar Oct 15 '24 12:10 RationalAsh

I think this is https://github.com/zed-industries/zed/pull/17885 and if you remove all the settings and check out the logs, you'll see what exactly Zed tries to autodetect.

To keep downloading the binaries as before, I use

  "lsp": {
    "rust-analyzer": {
      "binary": {
        "ignore_system_version": true
      }
    }
  }

SomeoneToIgnore avatar Oct 15 '24 12:10 SomeoneToIgnore

I also encountered this issue, how can I fix it?

zwishing avatar Oct 16 '24 04:10 zwishing

@Zwishing Does this help? What is in your logs?

SomeoneToIgnore avatar Oct 16 '24 05:10 SomeoneToIgnore

I think this is #17885 and if you remove all the settings and check out the logs, you'll see what exactly Zed tries to autodetect.

To keep downloading the binaries as before, I use

  "lsp": {
    "rust-analyzer": {
      "binary": {
        "ignore_system_version": true
      }
    }
  }

I actually just tried this and it doesn't seem to work and results in the same error.

RationalAsh avatar Oct 16 '24 13:10 RationalAsh

I had the same problem.

I had an old version in: /Users/jruz/Library/Application Support/Zed/languages/rust-analyzer so renamed rust-analyzer-2024-10-07 to rust-analyzer-2024-10-14 And is working for now

jruz avatar Oct 21 '24 00:10 jruz

I had the same issue and used this interim solution which makes Zed to use the rust-analyzer binary from the toolchain. The issue somehow appears to be related with the download/install process.

https://github.com/zed-industries/zed/issues/20648#issuecomment-2486683186

gvelim avatar Nov 19 '24 21:11 gvelim

@zwishing Does this help? What is in your logs? it works now

zwishing avatar Nov 22 '24 01:11 zwishing

Did receive the same error message. I noticed that I also got 2 versions of rust-analyzer in the specified directory. The newer one wasn't even set as executable (on linux). It's size also was just around 10M vs. 44MB of the older version. Simply removed the newer version and restarted Zed. Zed re-downloaded the rust-analyzer and removed the old version. The freshly received rust-analyzer binary is now also executable and has a size of 44MB. My guess is that the binary didn't fully downloaded the first time which would explain why it couldn't be used by zed.

timptner avatar Dec 01 '24 15:12 timptner

I changed the shell to fish and got the same error, removing the rust-analyzer binary from Zed folder did the trick, after Zed redownloaded it, everything worked

medvedNick avatar Jan 06 '25 14:01 medvedNick

just rm -rf /Users/xxx/Library/Application\ Support/Zed/languages/rust-analyzer/* I happened to close zed when it is updating rust-analyzer

hikaricai avatar Jan 06 '25 14:01 hikaricai

just rm -rf /Users/xxx/Library/Application\ Support/Zed/languages/rust-analyzer/* I happened to close zed when it is updating rust-analyzer

This worked for me also

talhadaar avatar Jan 31 '25 10:01 talhadaar

just rm -rf /Users/xxx/Library/Application\ Support/Zed/languages/rust-analyzer/* I happened to close zed when it is updating rust-analyzer

yeah this worked for me,

zed should give option to update the lsp

KMJ-007 avatar Feb 02 '25 10:02 KMJ-007

just rm -rf /Users/xxx/Library/Application\ Support/Zed/languages/rust-analyzer/* I happened to close zed when it is updating rust-analyzer

My OS is fedora and this worked for me (delete /home/user/.local/share/zed/languages/rust-analyzer/*) seems like the newer analyzer download failed (the executable size before delete is 20M and after delete is come to 40M and worked normally)

hrl10 avatar May 26 '25 13:05 hrl10

just rm -rf /Users/xxx/Library/Application\ Support/Zed/languages/rust-analyzer/* I happened to close zed when it is updating rust-analyzer

my rust analyzer was somehow corrupted, doing this solved for me. thanks!

desamtralized avatar Jul 29 '25 21:07 desamtralized