Skip to content

fix(crate_universe): pass OUTPUT_BASE as --output_base startup flag to bazel info - #4183

Merged
UebelAndre merged 1 commit into
bazelbuild:mainfrom
georgesfarah:fix/pass-output-base-startup-flag-to-bazel-info
Jul 30, 2026
Merged

fix(crate_universe): pass OUTPUT_BASE as --output_base startup flag to bazel info#4183
UebelAndre merged 1 commit into
bazelbuild:mainfrom
georgesfarah:fix/pass-output-base-startup-flag-to-bazel-info

Conversation

@georgesfarah

@georgesfarah georgesfarah commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Problem

The OUTPUT_BASE env var was added to let CI environments supply the output_base without relying on bazel info. However, the override is applied after parsing the bazel info output:

let output = process::Command::new(bazel).arg("info")...output()?;
if !output.status.success() {
    bail!(output.status)    // <-- bails here when output_base is not writable
}
// ... parse output ...
if let Ok(path) = env::var("OUTPUT_BASE") {  // <-- never reached
    bazel_info.insert(...);
}

When bazel info fails (e.g. the default ~/.cache/bazel/... is not writable in a sandboxed CI), the function bails before OUTPUT_BASE is ever checked — making the env var useless for its intended purpose.

Fix

Pass OUTPUT_BASE as a --output_base Bazel startup flag (before the subcommand):

bazel --output_base=/path/to/base info release output_base

Startup flags take effect before Bazel accesses any path, so it never touches the default (possibly non-writable) output_base. The bazel info subprocess runs normally and the post-parsing override is no longer needed.

Changes

  • crate_universe/src/cli/vendor.rs: restructure BazelInfo::try_new to optionally inject --output_base as a startup flag; remove the post-parsing OUTPUT_BASE override.
  • Removed test_parse_bazel_info_output_base_env_override since parse_bazel_info no longer handles the OUTPUT_BASE override — the existing test_bazel_info already covers the parsing logic.

@UebelAndre UebelAndre left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thank you!

@georgesfarah
georgesfarah force-pushed the fix/pass-output-base-startup-flag-to-bazel-info branch 5 times, most recently from f0cb03b to 821555f Compare July 30, 2026 18:14
…o bazel info

The OUTPUT_BASE env var was added to let CI environments supply the
output_base without relying on `bazel info`. However, the override
was applied after parsing the output, so it only worked when
`bazel info` itself succeeded — defeating its purpose.

When `bazel info` fails (e.g. the default output_base path is not
writable in a sandboxed CI environment), the function bails before
the override is ever reached.

Fix by passing OUTPUT_BASE as a `--output_base` Bazel startup flag
(which must precede the subcommand):

    bazel --output_base=/path/to/base info release output_base

Bazel uses the caller-specified path from the start and never
touches the default path. The post-parsing override is removed,
along with a formatting bug it carried (it inserted
`"output_base: /path"` as the map value instead of `"/path"`).
@georgesfarah
georgesfarah force-pushed the fix/pass-output-base-startup-flag-to-bazel-info branch from 821555f to 4cf1549 Compare July 30, 2026 18:17
@UebelAndre
UebelAndre enabled auto-merge July 30, 2026 18:23
@UebelAndre
UebelAndre added this pull request to the merge queue Jul 30, 2026
Merged via the queue into bazelbuild:main with commit 02749ca Jul 30, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants