Skip to content

Commit

Permalink
Warn about problems determining bazel version
Browse files Browse the repository at this point in the history
Instead of exiting silently, inform the user about the problem and carry on.

Do not require a Bazel executable up front so we are still able to generate a project.
  • Loading branch information
avdv committed Dec 4, 2024
1 parent 5e0f91b commit 43b5e92
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions start
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,22 @@ have () {
check_bazel_version () {
if ! have bazel; then
# shellcheck disable=SC2016
stderr 'Warning: cannot find `bazel` executable in $PATH'
stderr 'Warning: cannot find `bazel` executable in $PATH (skipping version check)'
return
fi
if ! actual_raw=$(bazel version | grep -E '^Build label:' | grep -Eo '[0-9.]+'); then
stderr 'Warning: cannot determine bazel version (skipping version check)'
return
fi
actual_raw=$(bazel version | grep -E '^Build label:' | grep -Eo '[0-9.]+')

# shellcheck disable=SC2034
IFS=. read -r actual_major actual_minor actual_patch <<-EOF
if ! IFS=. read -r actual_major actual_minor actual_patch <<-EOF
${actual_raw}
EOF
then
stderr "Warning: cannot parse version from bazel output (skipping version check)"
return
fi

expected_min="${MIN_BAZEL_MAJOR}.${MIN_BAZEL_MINOR}.0"
expected_max="${MAX_BAZEL_MAJOR}.${MAX_BAZEL_MINOR}.x"
Expand Down

0 comments on commit 43b5e92

Please sign in to comment.