rust-lang / rust-lang/rust-analyzer

Failure to load workspace from VS Code in FHS on NixOS

Open
#18,293 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

Has something changed in the way the VS Code extension launches the rust-analyzer server, in the last few months?

I'm running VS code on NixOS using an FHS setup so that VS Code and its extensions see what looks like a normal Linux. When I last used it a few months ago, rust-analzer worked perfectly in this setup, but when I went back to it yesterday (with updated VS Code and extensions), rust-analyzer now fails to load the workspace with error

cd "/home/me/myproject" && "/usr/bin/cargo" "--version" failed, exit status: 1
stderr:
error: command failed: 'cargo': No such file or directory (os error 2)

It seems that the language server is being launched in such a way that it is outside the FHS environment, so it can't find cargo where it expects it. Inside the FHS, cargo is indeed at /usr/bin/cargo. Previously, this wasn't an issue, so either it is being launched differently, or its expectations are different.

Any pointes greatly appreciated.

OS: NixOS Linux x64 6.6.50
VS Code: 1.93.0 in FHS environment including rustup
rust-analyser extension: 0.3.2137 from marketplace
rust-analyzer: 0.3.2137 from extension
rust toolchain: 1.77 from rustup

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the workspace load in the reported NixOS FHS setup with VS Code 1.93.0 and rust-analyzer 0.3.2137, then trace how the VS Code extension launches the server and invokes cargo. Done means rust-analyzer can find /usr/bin/cargo inside the FHS environment and load the workspace successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, vscode
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.