fix(crate_universe): fix OUTPUT_BASE env var value format in crates_vendor#4102
Open
georgesfarah wants to merge 1 commit into
Open
fix(crate_universe): fix OUTPUT_BASE env var value format in crates_vendor#4102georgesfarah wants to merge 1 commit into
georgesfarah wants to merge 1 commit into
Conversation
|
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. |
52e7ce9 to
f6bf0fc
Compare
…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.
f6bf0fc to
60036d4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix the
OUTPUT_BASEenvironment variable override incrate_universe/src/cli/vendor.rs— it has never worked correctly.Bug
The
bazel infooutput parser splits each line on:and stores only the part after the colon as the HashMap value:So for output like
output_base: /data/output, the HashMap contains{"output_base" => "/data/output"}.However, the
OUTPUT_BASEenv var override stores the full formatted string as the value:This produces
{"output_base" => "output_base: /data/output"}. WhenTryFromlater converts this to aPathBufvia.map(Into::into), it producesPathBuf("output_base: /data/output")— an invalid path.Fix
Store the raw path string without the prefix:
Also extract
parse_bazel_infofromtry_newso the parsing and env var override logic can be unit-tested without spawning abazel infosubprocess.Test plan
Added
test_parse_bazel_info_output_base_env_overridewhich verifies:OUTPUT_BASEset, the parsed value frombazel infooutput is usedOUTPUT_BASEset, it overrides the parsed value with the correct path