From de281090d17c0fc7bf47354e833423cf5c3c5137 Mon Sep 17 00:00:00 2001 From: Ronny Chevalier Date: Thu, 21 Dec 2023 23:51:26 +0100 Subject: [PATCH] fix(multivers): do not propagate CARGO_UNSTABLE_BUILD_STD to the runner build If a user adds `-Zbuild-std` to the command line to rebuild the std it is only propagated to the build of each version, but not the runner. These flags, however, can also be configured with [environment variables](https://github.com/rust-lang/cargo/pull/8393). So if a user uses the `CARGO_UNSTABLE_BUILD_STD` environment variable to rebuild the std of the crate, it is propagated to the build of the runner. Since the runner adds `panic=abort`, if the user does not add `CARGO_UNSTABLE_BUILD_STD=std,panic_abort`, there are duplicate lang item errors. These errors might be confusing since the build of the runner is not necessarily known, and its profile even less. See #7 --- CHANGELOG.md | 4 ++++ src/runner.rs | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6634c3c..6ccefda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/). ## [Unreleased] +### Fixed + +- Do not propagate the `CARGO_UNSTABLE_BUILD_STD` environment variable to the build of the runner (#7). + [Unreleased]: https://github.com/ronnychevalier/cargo-multivers/compare/v0.7.0...HEAD ## [0.7.0] - 18-12-2023 diff --git a/src/runner.rs b/src/runner.rs index 1cd6798..e91eee6 100644 --- a/src/runner.rs +++ b/src/runner.rs @@ -78,11 +78,16 @@ impl RunnerBuilder { builds_path: &Path, original_filename: &OsStr, ) -> anyhow::Result { + // We do not propagate `CARGO_UNSTABLE_BUILD_STD` since if `panic_abort` is not + // specified, the build of the runner will fail (since its profile specifies `panic=abort`). + // A proper fix could be to clear the whole environment before spawning this `cargo build`, + // but until `CargoBuild` exposes the `Command` or this function, we can only do this. let cargo = CargoBuild::new() .release() .target(target) .target_dir(&self.output_directory) .manifest_path(&self.manifest_path) + .env_remove("CARGO_UNSTABLE_BUILD_STD") .env("MULTIVERS_BUILDS_DESCRIPTION_PATH", builds_path); let cargo = cargo