rust-lang / rust-lang/rust-analyzer

rust-analyzer is ignoring "server.path" (either because of "remote" workspace, or NixOS, or both)

Open
#11,559 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

On NixOS, with code-server, rust-analyzer blows up before it even get a chance:

INFO [2/25/2022, 9:23:22 PM]: PersistentState: { serverVersion: undefined }
ERROR [2/25/2022, 9:23:22 PM]: Bootstrap error [Error: error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I)

       at «stdin»:2:36:

            1|
            2|             {srcStr, pkgs ? import <nixpkgs> {}}:
             |                                    ^
            3|                 pkgs.stdenv.mkDerivation {
(use '--show-trace' to show detailed location information)

	at /home/cole/.local/share/code-server/extensions/matklad.rust-analyzer-0.3.939/out/main.js:97:291
	at ChildProcess.exithandler (child_process.js:390:5)
	at ChildProcess.emit (events.js:400:28)
	at maybeClose (internal/child_process.js:1058:16)
	at Socket.<anonymous> (internal/child_process.js:443:11)
	at Socket.emit (events.js:400:28)
	at Pipe.<anonymous> (net.js:686:12)]
  1. The patching that it does is rather brittle, has no escape hatch, requires NIX_PATH be set.
  2. It seems that rust-analyzer.server.path is ignored when rust-analyzer is used on a remote workspace. I've done this in the past, I'm pretty sure things will just work if this were respected and used instead of the patching path.

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 tracing the remote-workspace bootstrap that leads to the reported extension path in out/main.js, then inspect how rust-analyzer.server.path is handled. Reproduce the NixOS failure with code-server and determine whether the setting is bypassed; done means a configured server.path is honored without requiring the brittle Nix-based patching path.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.