Skip to content

Commit 9755978

Browse files
committed
fix(sbom): Don't set CARGO_SBOM_PATH when empty (like stable)
Noticed `CARGO_SBOM_PATH` was being set when playing around with artifact-deps. I could have gated the env by whether the nightly feature was enabled but figured it would be better to not set if it there aren't SBOMs.
1 parent 2b7dac9 commit 9755978

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/cargo/core/compiler/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -780,8 +780,11 @@ fn prepare_rustc(build_runner: &BuildRunner<'_, '_>, unit: &Unit) -> CargoResult
780780

781781
if is_primary {
782782
base.env("CARGO_PRIMARY_PACKAGE", "1");
783-
let file_list = std::env::join_paths(build_runner.sbom_output_files(unit)?)?;
784-
base.env("CARGO_SBOM_PATH", file_list);
783+
let file_list = build_runner.sbom_output_files(unit)?;
784+
if !file_list.is_empty() {
785+
let file_list = std::env::join_paths(file_list)?;
786+
base.env("CARGO_SBOM_PATH", file_list);
787+
}
785788
}
786789

787790
if unit.target.is_test() || unit.target.is_bench() {

tests/testsuite/sbom.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fn warn_without_passing_unstable_flag() {
3838
[COMPILING] foo v0.5.0 ([ROOT]/foo)
3939
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
4040
[RUNNING] `target/debug/foo[EXE]`
41-
Some("")
41+
None
4242
4343
"#]])
4444
.run();

0 commit comments

Comments
 (0)