rust-analyzer discovery reports un-expanded CARGO_MANIFEST_DIR environment variable

Open
#4,281 1 comment 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 3 days

@UebelAndre is already working on this.

Since Sep 30, 2026.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
64/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
rust

Research direction

Start by locating discover_bazel_rust_project and trace how it passes CARGO_MANIFEST_DIR to process_wrapper during rust-analyzer discovery. Reproduce with a binary depending on bevy_ecs and confirm the environment variable is reported unexpanded. Done means the discovered value works for proc macros such as Bevy without the invalid-variable error.

Written by the indexing model from the issue text.

Description

awaiting-response rust-analyzer

Description
Trying to use proc macros that rely on CARGO_MANIFEST_DIR (e.g. Bevy) results in errors about CARGO_MANIFEST_DIR being invalid:

Image

After doing some digging, it seems the problem is that discover_bazel_rust_project reports the CARGO_MANIFEST_DIR without expanding for process_wrapper:

Image

Reproduction steps

  • Create new simple binary project.
  • Depend on `bevy_ecs = "0.19.1"
  • Add the following code:
use bevy_ecs::prelude::*;

#[derive(Component, Default)]
pub struct Camera {

}
  • Install rust-analyzer as per repo instructions

Impact
Definitely makes using rules_rust with crates like Bevy impractical at the moment.

Bazel and rules_rust version

bazel_dep(name = "rules_rs", version = "0.0.112")

Bazel 9.2.0 from Homebrew.

Dominant language
Starlark
Stars
857
Forks
701
Avg merge
4d 7h
Merged PRs (30d)
46

Getting set up

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.

More from bazelbuild/rules_rust

All issues in bazelbuild/rules_rust

Similar issues

More Build System issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.