Skip to content

Commit

Permalink
fix(multivers): do not propagate CARGO_UNSTABLE_BUILD_STD to the runn…
Browse files Browse the repository at this point in the history
…er 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](rust-lang/cargo#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
  • Loading branch information
ronnychevalier committed Dec 21, 2023
1 parent 28beed6 commit de28109
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,16 @@ impl RunnerBuilder {
builds_path: &Path,
original_filename: &OsStr,
) -> anyhow::Result<PathBuf> {
// 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
Expand Down

0 comments on commit de28109

Please sign in to comment.