rust-lang / rust-lang/cargo

rerun-if-env-changed=CARGO_MANIFEST_DIR changing doesn't trigger a rebuild on change

Open
#8,693 14 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-build-scripts A-environment-variables A-rebuild-detection S-needs-info
Dominant language
Rust
Stars
15.5k
Forks
3k
Avg merge
23h 30m
Merged PRs (30d)
51

Description

CARGO_MANIFEST_DIR changing doesn't trigger a rebuild, even if rerun-if-env-changed=CARGO_MANIFEST_DIR is specified in the build.rs.

Thus env!("CARGO_MANIFEST_DIR") and env::var("CARGO_MANIFEST_DIR").unwrap() can differ in binaries executed by cargo run/test/bench.

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 issue with a build.rs that specifies rerun-if-env-changed=CARGO_MANIFEST_DIR, then run the affected cargo run, cargo test, and cargo bench workflows. Done means changing CARGO_MANIFEST_DIR triggers a rebuild and env!("CARGO_MANIFEST_DIR") agrees with env::var("CARGO_MANIFEST_DIR").

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.