Skip to content

fix(crate_universe): fix OUTPUT_BASE env var value format in crates_vendor#4102

Open
georgesfarah wants to merge 1 commit into
bazelbuild:mainfrom
georgesfarah:fix/output-base-env-value-format
Open

fix(crate_universe): fix OUTPUT_BASE env var value format in crates_vendor#4102
georgesfarah wants to merge 1 commit into
bazelbuild:mainfrom
georgesfarah:fix/output-base-env-value-format

Conversation

@georgesfarah

@georgesfarah georgesfarah commented Jun 25, 2026

Copy link
Copy Markdown

Summary

Fix the OUTPUT_BASE environment variable override in crate_universe/src/cli/vendor.rs — it has never worked correctly.

Bug

The bazel info output parser splits each line on : and stores only the part after the colon as the HashMap value:

let (k, v) = line.split_at(line.find(':')?);
Ok((k.to_string(), (v[1..]).trim().to_string()))

So for output like output_base: /data/output, the HashMap contains {"output_base" => "/data/output"}.

However, the OUTPUT_BASE env var override stores the full formatted string as the value:

bazel_info.insert("output_base".to_owned(), format!("output_base: {}", path));

This produces {"output_base" => "output_base: /data/output"}. When TryFrom later converts this to a PathBuf via .map(Into::into), it produces PathBuf("output_base: /data/output") — an invalid path.

Fix

Store the raw path string without the prefix:

bazel_info.insert("output_base".to_owned(), path);

Also extract parse_bazel_info from try_new so the parsing and env var override logic can be unit-tested without spawning a bazel info subprocess.

Test plan

Added test_parse_bazel_info_output_base_env_override which verifies:

  • Without OUTPUT_BASE set, the parsed value from bazel info output is used
  • With OUTPUT_BASE set, it overrides the parsed value with the correct path

@google-cla

google-cla Bot commented Jun 25, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@georgesfarah georgesfarah force-pushed the fix/output-base-env-value-format branch 3 times, most recently from 52e7ce9 to f6bf0fc Compare June 25, 2026 09:19
…endor

The OUTPUT_BASE env var override inserted
`format!("output_base: {}", path)` as the HashMap value. However, the
`bazel info` output parser splits each line on `:` and stores only the
part after the colon as the value:

    let (k, v) = line.split_at(line.find(':')?);
    Ok((k.to_string(), (v[1..]).trim().to_string()))

So for `bazel info` output like "output_base: /data/output", the HashMap
contains {"output_base" => "/data/output"}.

But the OUTPUT_BASE override stored the FULL formatted string as the
value: {"output_base" => "output_base: /data/output"}. When TryFrom
later converts this to a PathBuf via `.map(Into::into)`, it produces
PathBuf("output_base: /data/output") — an invalid path.

This means the OUTPUT_BASE env var has never worked correctly. Fix by
storing the raw path string without the prefix.

Also extract `parse_bazel_info` from `try_new` so the parsing and env
var override logic can be unit-tested without spawning a subprocess.
@georgesfarah georgesfarah force-pushed the fix/output-base-env-value-format branch from f6bf0fc to 60036d4 Compare June 25, 2026 09:23
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.

1 participant