rust-lang / rust-lang/rust-analyzer

The rust-analyzer plugin for VS code uses "-Zscript" on stable when linked-projects isn't specified

Open
#20,515 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

When using the rust-analyzer plugin for VS Code, by default it adds the "-ZScript" argument, causing it to fail. When I open Cargo.toml followed by src/main.rs, I get the following:

2025-08-22T11:30:59.952492362-07:00 ERROR Flycheck failed to run the following command: CommandHandle { program: "/home/nate/.cargo/bin/cargo", arguments: ["check", "--workspace", "--message-format=json-diagnostic-rendered-ansi", "--manifest-path", "/home/nate/projects/hello-world/src/main.rs", "-Zscript", "--keep-going", "--all-targets"], current_dir: Some("/home/nate/projects/hello-world/src") }, error=Cargo watcher failed, the command produced no valid metadata (exit code: ExitStatus(unix_wait_status(25856))):
error: the `-Z` flag is only accepted on the nightly channel of Cargo, but this is the `stable` channel
See https://doc.rust-lang.org/book/appendix-07-nightly-rust.html for more information about Rust release channels.

I also see these errors if opening main.rs before opening Cargo.toml:

2025-08-22T11:31:19.933877147-07:00 ERROR FetchWorkspaceError: rust-analyzer failed to fetch workspace
2025-08-22T11:31:20.093173618-07:00 ERROR FetchWorkspaceError: rust-analyzer failed to fetch workspace

Adding the Cargo.toml file to rust-analyzer.linkedProjects fixes this, but it doesn't seem like this should be necessary; rust-analyzer should be able to locate Cargo.toml automatically (unless I'm missing something about how it works). And in any case, it should never add -Zscript on stable Rust.

This is on a new installation of Ubuntu, with the latest version of stable Rust and VSCodium, with almost entirely default settings. It happens with every project I've tried, including one newly created with "cargo new hello-world".

rust-analyzer version: 0.3.2577-standalone [/home/nate/.vscode-oss/extensions/rust-lang.rust-analyzer-0.3.2577-linux-x64/server/rust-analyzer]

rustc 1.89.0 (29483883e 2025-08-04)

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

Reproduce the failure by opening Cargo.toml and src/main.rs in VS Code with stable Rust, then inspect rust-analyzer's Cargo project discovery and flycheck command setup. Done means a default project locates Cargo.toml automatically and does not receive -Zscript when Cargo runs on stable.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, vscode
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.