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

## 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:

```rust
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.
1 file changed
tree: 934cc5ee4f075b0c475bc0ffe6d15d132ed02259
  1. .bazelci/
  2. .bcr/
  3. .github/
  4. cargo/
  5. crate_universe/
  6. docs/
  7. examples/
  8. extensions/
  9. ffi/
  10. nix/
  11. rust/
  12. test/
  13. tools/
  14. util/
  15. .bazelignore
  16. .bazelrc
  17. .clang-format
  18. .clippy.toml
  19. .envrc
  20. .gitattributes
  21. .gitignore
  22. .pre-commit-config.yaml
  23. .prettierrc.toml
  24. .rustfmt.toml
  25. .typos.toml
  26. ARCHITECTURE.md
  27. AUTHORS
  28. BUILD.bazel
  29. CODEOWNERS
  30. COMPATIBILITY.md
  31. CONTRIBUTING.md
  32. CONTRIBUTORS
  33. LICENSE.txt
  34. MODULE.bazel
  35. README.md
  36. version.bzl
  37. WORKSPACE.bazel
README.md

Rust Rules

  • Postsubmit Build status

Overview

This repository provides rules for building Rust projects with Bazel.

Starter repo

The fastest way to try this in an empty project is to click the green “Use this template” button on https://github.com/bazel-starters/rust.

Community

General discussions and announcements take place in the GitHub Discussions, but there are additional places where community members gather to discuss rules_rust.

Documentation

Please refer to the full documentation.