From a08be1fcad72ed2b195b1394e0675f18ace3fa0d Mon Sep 17 00:00:00 2001 From: Dmitri Plotnikov Date: Wed, 17 Jun 2026 18:52:40 -0700 Subject: [PATCH] Fix Windows bazel build by unsetting ANDROID_HOME Prevent transitive rules_android dependency from attempting to configure an Android SDK repository on CI environments where ANDROID_HOME is set but contains an incompatible Android SDK build tools version. PiperOrigin-RevId: 934041346 --- .bazelrc | 4 ++++ release/kokoro/presubmit_windows.bat | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.bazelrc b/.bazelrc index a727ae9..5c70e99 100644 --- a/.bazelrc +++ b/.bazelrc @@ -2,6 +2,10 @@ # This allows Bazel to automatically pick up the `windows` config on Windows. common --enable_platform_specific_config +# Prevent rules_android (pulled in transitively) from attempting to configure an Android SDK repository +# using the preinstalled Android SDK on CI machines (e.g. Kokoro Windows), which fails build tools version checks. +common --repo_env=ANDROID_HOME= + # Disable automatic creation of `__init__.py` files, which prevent multiple # workspaces from providing files with the same package prefix (e.g., "cel"). # See https://github.com/bazelbuild/rules_python/issues/330. diff --git a/release/kokoro/presubmit_windows.bat b/release/kokoro/presubmit_windows.bat index 30136f1..5e9e8ea 100644 --- a/release/kokoro/presubmit_windows.bat +++ b/release/kokoro/presubmit_windows.bat @@ -56,7 +56,7 @@ for %%V in (%PYTHON_VERSIONS%) do ( :fetch_loop set /a ATTEMPTS+=1 echo Fetch attempt !ATTEMPTS! of !FETCH_RETRIES!... - bazel %STARTUP_FLAGS% fetch //... > fetch.log 2>&1 + bazel !STARTUP_FLAGS! fetch //... > fetch.log 2>&1 set FETCH_STATUS=!ERRORLEVEL! type fetch.log if !FETCH_STATUS! NEQ 0 ( @@ -78,7 +78,7 @@ for %%V in (%PYTHON_VERSIONS%) do ( if exist fetch.log del fetch.log echo --- Getting Output Base --- - for /f "tokens=*" %%i in ('bazel %STARTUP_FLAGS% info output_base') do set "OUTPUT_BASE=%%i" + for /f "tokens=*" %%i in ('bazel !STARTUP_FLAGS! info output_base') do set "OUTPUT_BASE=%%i" set "OUTPUT_BASE=!OUTPUT_BASE:/=\!" echo Output Base: !OUTPUT_BASE! @@ -99,7 +99,7 @@ for %%V in (%PYTHON_VERSIONS%) do ( ) echo --- Bazel Build --- - bazel %STARTUP_FLAGS% build %LINK_FLAGS% //... + bazel !STARTUP_FLAGS! build !LINK_FLAGS! //... if !ERRORLEVEL! NEQ 0 ( echo Build failed! set "PRESUBMIT_STATUS=1" @@ -107,7 +107,7 @@ for %%V in (%PYTHON_VERSIONS%) do ( ) echo --- Bazel Test Python %%V --- - bazel %STARTUP_FLAGS% test %LINK_FLAGS% --test_output=errors //... + bazel !STARTUP_FLAGS! test !LINK_FLAGS! --test_output=errors //... if !ERRORLEVEL! NEQ 0 ( echo Tests failed for Python %%V! set "PRESUBMIT_STATUS=1"