Skip to content

Commit c3122ce

Browse files
committed
add documentation for CARGO_WORKSPACE_DIR env var
1 parent 4cbeb69 commit c3122ce

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/cargo/core/compiler/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,9 @@ fn prepare_rustc(
728728
base.env("CARGO_TARGET_TMPDIR", tmp.display().to_string());
729729

730730
if cx.bcx.config.nightly_features_allowed {
731-
// relative path from manifest directory to workspace directory
731+
// Use a relative path and limit to integration tests and benchmarks in hopes
732+
// that it conveys to the user that the meaning of this value is a bit fuzzy
733+
// (very different meaning in the original repo vs once published).
732734
let cargo_workspace_dir = pathdiff::diff_paths(cx.bcx.ws.root(), unit.pkg.root())
733735
.expect("both paths are absolute");
734736
base.env(

src/doc/src/reference/environment-variables.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,12 @@ corresponding environment variable is set to the empty string, `""`.
257257
where integration tests or benchmarks are free to put any data needed by
258258
the tests/benches. Cargo initially creates this directory but doesn't
259259
manage its content in any way, this is the responsibility of the test code.
260+
* `CARGO_WORKSPACE_DIR` --- Only set when building [integration test] or benchmark code.
261+
This is a path to the workspace directory. If the current package is not part of
262+
a workspace, it is a path to the directory containing the manifest of the package.
263+
For a published registry crate it is a path to the directory containing the manifest
264+
of the package that (possibly transitively) imported that published crate.
265+
Currently, it is implemented as a relative path.
260266

261267
[Cargo target]: cargo-targets.md
262268
[binaries]: cargo-targets.md#binaries

0 commit comments

Comments
 (0)