Neutralize rules_android from tools/bazel* for the time being#49125
Conversation
### What does this PR do?
Unsets `ANDROID_HOME` in `tools/bazel*` right before invoking `bazel`.
### Motivation
We transitively depend on `rules_android` 0.6.4 that reads
`ANDROID_HOME` to locate an Android SDK.
GitHub Actions ubuntu-24.04 runners have one (partially?) installed, so
the `android_sdk_repository_extension` generates a full `@androidsdk`
repo that loads `helper.bzl`, which transitively references `CcInfo` as
a `bazel` global.
That global was removed in `bazel` 9, causing analysis to fail at times
with:
```
The CcInfo symbol has been removed, add the following to your
BUILD/bzl file: load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")
```
(https://github.com/DataDog/datadog-agent/actions/runs/24135010393/job/70420742307#step:11:1684)
Unsetting `ANDROID_HOME` causes the extension to generate a stub repo
instead, with no `CcInfo` reference.
### Describe how you validated your changes
Reproduced locally with:
```
mkdir -p /tmp/fake-sdk/platforms/android-34
ANDROID_HOME=/tmp/fake-sdk bazel run //bazel/tools:go_mod_tidy_all
```
Build fails without the fix, succeeds with it.
### Additional Notes
**The proper long-term fix is `--experimental_strict_repo_env`, which
prevents repo rules from reading undeclared environment variables.
43d1a91 to
36a3478
Compare
Files inventory check summaryFile checks results against ancestor cef5fd28: Results for datadog-agent_7.79.0~devel.git.563.36a3478.pipeline.106898794-1_amd64.deb:No change detected |
Regression DetectorRegression Detector ResultsMetrics dashboard Baseline: 15312f5 Optimization Goals: ✅ No significant changes detected
|
| perf | experiment | goal | Δ mean % | Δ mean % CI | trials | links |
|---|---|---|---|---|---|---|
| ➖ | docker_containers_cpu | % cpu utilization | +1.12 | [-1.87, +4.11] | 1 | Logs |
Fine details of change detection per experiment
| perf | experiment | goal | Δ mean % | Δ mean % CI | trials | links |
|---|---|---|---|---|---|---|
| ➖ | tcp_syslog_to_blackhole | ingress throughput | +2.53 | [+2.34, +2.72] | 1 | Logs |
| ➖ | quality_gate_metrics_logs | memory utilization | +1.75 | [+1.51, +1.99] | 1 | Logs bounds checks dashboard |
| ➖ | docker_containers_cpu | % cpu utilization | +1.12 | [-1.87, +4.11] | 1 | Logs |
| ➖ | docker_containers_memory | memory utilization | +0.42 | [+0.34, +0.50] | 1 | Logs |
| ➖ | otlp_ingest_logs | memory utilization | +0.28 | [+0.17, +0.38] | 1 | Logs |
| ➖ | otlp_ingest_metrics | memory utilization | +0.07 | [-0.09, +0.24] | 1 | Logs |
| ➖ | file_to_blackhole_1000ms_latency | egress throughput | +0.07 | [-0.35, +0.50] | 1 | Logs |
| ➖ | quality_gate_idle_all_features | memory utilization | +0.05 | [+0.01, +0.08] | 1 | Logs bounds checks dashboard |
| ➖ | uds_dogstatsd_to_api | ingress throughput | +0.02 | [-0.19, +0.23] | 1 | Logs |
| ➖ | file_to_blackhole_100ms_latency | egress throughput | +0.01 | [-0.10, +0.12] | 1 | Logs |
| ➖ | tcp_dd_logs_filter_exclude | ingress throughput | +0.00 | [-0.10, +0.11] | 1 | Logs |
| ➖ | uds_dogstatsd_to_api_v3 | ingress throughput | -0.00 | [-0.21, +0.20] | 1 | Logs |
| ➖ | file_to_blackhole_500ms_latency | egress throughput | -0.03 | [-0.44, +0.37] | 1 | Logs |
| ➖ | file_to_blackhole_0ms_latency | egress throughput | -0.04 | [-0.60, +0.52] | 1 | Logs |
| ➖ | ddot_metrics_sum_delta | memory utilization | -0.07 | [-0.25, +0.10] | 1 | Logs |
| ➖ | quality_gate_logs | % cpu utilization | -0.10 | [-1.72, +1.53] | 1 | Logs bounds checks dashboard |
| ➖ | ddot_metrics_sum_cumulative | memory utilization | -0.11 | [-0.24, +0.03] | 1 | Logs |
| ➖ | ddot_metrics_sum_cumulativetodelta_exporter | memory utilization | -0.13 | [-0.36, +0.09] | 1 | Logs |
| ➖ | quality_gate_idle | memory utilization | -0.14 | [-0.18, -0.09] | 1 | Logs bounds checks dashboard |
| ➖ | ddot_metrics | memory utilization | -0.24 | [-0.42, -0.05] | 1 | Logs |
| ➖ | file_tree | memory utilization | -0.24 | [-0.30, -0.19] | 1 | Logs |
| ➖ | ddot_logs | memory utilization | -0.25 | [-0.32, -0.19] | 1 | Logs |
| ➖ | uds_dogstatsd_20mb_12k_contexts_20_senders | memory utilization | -0.28 | [-0.34, -0.22] | 1 | Logs |
Bounds Checks: ✅ Passed
| perf | experiment | bounds_check_name | replicates_passed | observed_value | links |
|---|---|---|---|---|---|
| ✅ | docker_containers_cpu | simple_check_run | 10/10 | 663 ≥ 26 | |
| ✅ | docker_containers_memory | memory_usage | 10/10 | 277.53MiB ≤ 370MiB | |
| ✅ | docker_containers_memory | simple_check_run | 10/10 | 694 ≥ 26 | |
| ✅ | file_to_blackhole_0ms_latency | memory_usage | 10/10 | 0.19GiB ≤ 1.20GiB | |
| ✅ | file_to_blackhole_0ms_latency | missed_bytes | 10/10 | 0B = 0B | |
| ✅ | file_to_blackhole_1000ms_latency | memory_usage | 10/10 | 0.23GiB ≤ 1.20GiB | |
| ✅ | file_to_blackhole_1000ms_latency | missed_bytes | 10/10 | 0B = 0B | |
| ✅ | file_to_blackhole_100ms_latency | memory_usage | 10/10 | 0.20GiB ≤ 1.20GiB | |
| ✅ | file_to_blackhole_100ms_latency | missed_bytes | 10/10 | 0B = 0B | |
| ✅ | file_to_blackhole_500ms_latency | memory_usage | 10/10 | 0.22GiB ≤ 1.20GiB | |
| ✅ | file_to_blackhole_500ms_latency | missed_bytes | 10/10 | 0B = 0B | |
| ✅ | quality_gate_idle | intake_connections | 10/10 | 3 = 3 | bounds checks dashboard |
| ✅ | quality_gate_idle | memory_usage | 10/10 | 176.77MiB ≤ 181MiB | bounds checks dashboard |
| ✅ | quality_gate_idle_all_features | intake_connections | 10/10 | 3 = 3 | bounds checks dashboard |
| ✅ | quality_gate_idle_all_features | memory_usage | 10/10 | 494.24MiB ≤ 550MiB | bounds checks dashboard |
| ✅ | quality_gate_logs | intake_connections | 10/10 | 3 ≤ 6 | bounds checks dashboard |
| ✅ | quality_gate_logs | memory_usage | 10/10 | 206.44MiB ≤ 220MiB | bounds checks dashboard |
| ✅ | quality_gate_logs | missed_bytes | 10/10 | 0B = 0B | bounds checks dashboard |
| ✅ | quality_gate_metrics_logs | cpu_usage | 10/10 | 372.62 ≤ 2000 | bounds checks dashboard |
| ✅ | quality_gate_metrics_logs | intake_connections | 10/10 | 4 ≤ 6 | bounds checks dashboard |
| ✅ | quality_gate_metrics_logs | memory_usage | 10/10 | 426.12MiB ≤ 475MiB | bounds checks dashboard |
| ✅ | quality_gate_metrics_logs | missed_bytes | 10/10 | 0B = 0B | bounds checks dashboard |
Explanation
Confidence level: 90.00%
Effect size tolerance: |Δ mean %| ≥ 5.00%
Performance changes are noted in the perf column of each table:
- ✅ = significantly better comparison variant performance
- ❌ = significantly worse comparison variant performance
- ➖ = no significant change in performance
A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".
For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:
-
Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.
-
Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.
-
Its configuration does not mark it "erratic".
CI Pass/Fail Decision
✅ Passed. All Quality Gates passed.
- quality_gate_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
- quality_gate_idle, bounds check intake_connections: 10/10 replicas passed. Gate passed.
- quality_gate_logs, bounds check missed_bytes: 10/10 replicas passed. Gate passed.
- quality_gate_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
- quality_gate_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
- quality_gate_metrics_logs, bounds check missed_bytes: 10/10 replicas passed. Gate passed.
- quality_gate_metrics_logs, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
- quality_gate_metrics_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
- quality_gate_metrics_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
- quality_gate_idle_all_features, bounds check intake_connections: 10/10 replicas passed. Gate passed.
- quality_gate_idle_all_features, bounds check memory_usage: 10/10 replicas passed. Gate passed.
### What does this PR do? Add `--experimental_strict_repo_env` (bazelbuild/bazel#28189): only PATH (and PATHEXT on Windows) plus variables explicitly forwarded via `--repo_env` are now visible to repository rules. Drop `--incompatible_strict_action_env`, which graduated to the default in Bazel 9. Forward `GOCACHE`, `GOMODCACHE`, and `XDG_CACHE_HOME` to all platforms via `--repo_env`. On Windows, also forward `PIP_CACHE_DIR`, `VSTUDIO_ROOT`, `SYSTEMDRIVE` (needed by vswhere to locate the VS installer instance database), `SYSTEMROOT` (needed by COM to load system DLLs), and `USERPROFILE` (needed by git to fetch repositories). Explicitly set `GOCACHE` in `tools/bazel[.bat]`: - on Linux, Go derives `GOCACHE` from `XDG_CACHE_HOME` so unsetting it was fine - neutral, - macOS does not honor XDG, so strict `repo_env` (which strips `HOME`) exposed the gap - fixed, - on Windows, `GOCACHE` was already set in the XDG branch but via `%XDG_CACHE_HOME%` (parse-time expansion) rather than `!XDG_CACHE_HOME!` (delayed), yielding a path with forward slashes before `XDG_CACHE_HOME` was normalised - fixed. When `XDG_CACHE_HOME` is absent, forward `GOCACHE` and `GOMODCACHE` to their official defaults, so Go repo rules always receive non-empty values for both. What's mentioned above allows to drop null environment overrides (`"GOPATH": None` from both `go_fast` and `go_sdk_overrides`, `"GOROOT": None` from `go_sdk_overrides` only): the flag already strips these from the repo-rule environment, making explicit unsetting redundant. Switch `_get_vs_property()` in `visual_studio.bzl` from `ctx.execute()` to `repo_utils.execute_checked()`, which: - fixes a pre-existing `fail()` format bug, - includes `stdout` in the error message automatically (`vswhere` prints to it), - overall bring a more actionable error output. Finally, remove the `ANDROID_HOME` workaround from `tools/bazel[.bat]` (follow-up of #49125). ### Motivation Without this flag, any variable set on the host leaks silently into repository rules, causing non-reproducible builds and cross-platform divergence. The `ANDROID_HOME` issue (`rules_android` generating a full `@androidsdk` repo referencing the Bazel-9-removed `CcInfo` global) is one concrete instance. ### Describe how you validated your changes - local Windows VM, - CI. ### Additional Notes - bazelbuild/bazel#27670 - bazelbuild/bazel#28189 - #48032 - #49125
### What does this PR do? Add `--experimental_strict_repo_env` (bazelbuild/bazel#28189): only PATH (and PATHEXT on Windows) plus variables explicitly forwarded via `--repo_env` are now visible to repository rules. Drop `--incompatible_strict_action_env`, which graduated to the default in Bazel 9. Forward `GOCACHE`, `GOMODCACHE`, and `XDG_CACHE_HOME` to all platforms via `--repo_env`. Forward `DEPLOY_AGENT`, `FORCED_PACKAGE_COMPRESSION_LEVEL`, `PACKAGE_VERSION`, and `SIGN_MAC` so that `@agent_volatile//:env_vars.bzl` continues to see them (they are read at Starlark load time and cannot be replaced with build flags). On Windows, also forward `PIP_CACHE_DIR`, `VSTUDIO_ROOT`, `SYSTEMDRIVE` (needed by vswhere to locate the VS installer instance database), `SYSTEMROOT` (needed by COM to load system DLLs), and `USERPROFILE` (needed by git to fetch repositories). Explicitly set `GOCACHE` in `tools/bazel[.bat]`: on Linux, Go derives `GOCACHE` from `XDG_CACHE_HOME` so unsetting it was fine; macOS does not honour XDG, so strict repo env (which strips `HOME`) exposed the gap. On Windows, `GOCACHE` was already set in the XDG branch but via `%XDG_CACHE_HOME%` (parse-time expansion) rather than `!XDG_CACHE_HOME!` (delayed), yielding a path with forward slashes before `XDG_CACHE_HOME` was normalised. Add an else branch to `tools/bazel[.bat]` forwarding `GOCACHE` and `GOMODCACHE` to their official defaults when `XDG_CACHE_HOME` is absent, so repo rules always receive non-empty values for both. Drop null environment overrides (`"GOPATH": None` from both `go_fast` and `go_sdk_overrides`, `"GOROOT": None` from `go_sdk_overrides` only): the flag already strips these from the repo-rule environment, making explicit unsetting redundant. Switch `_get_vs_property()` in `visual_studio.bzl` from `ctx.execute()` to `repo_utils.execute_checked()`, fixing a pre-existing `fail()` format bug and including stdout+stderr in error output automatically. Remove the `ANDROID_HOME` workaround from `tools/bazel[.bat]` (#49125), whose commit message identified this flag as the intended fix. ### Motivation Without this flag, any variable set on the host leaks silently into repository rules, causing non-reproducible builds and cross-platform divergence. The ANDROID_HOME issue (rules_android generating a full @AndroidSDK repo referencing the Bazel-9-removed CcInfo global) is one concrete instance; GOMODCACHE leaking into go_fast is another. ### Describe how you validated your changes CI. ### Additional Notes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
### What does this PR do? Add `--experimental_strict_repo_env` (bazelbuild/bazel#28189): only PATH (and PATHEXT on Windows) plus variables explicitly forwarded via `--repo_env` are now visible to repository rules. Drop `--incompatible_strict_action_env`, which graduated to the default in Bazel 9. Forward `GOCACHE`, `GOMODCACHE`, and `XDG_CACHE_HOME` to all platforms via `--repo_env`. Forward `DEPLOY_AGENT`, `FORCED_PACKAGE_COMPRESSION_LEVEL`, `PACKAGE_VERSION`, and `SIGN_MAC` so that `@agent_volatile//:env_vars.bzl` continues to see them (they are read at Starlark load time and cannot be replaced with build flags). On Windows, also forward `PIP_CACHE_DIR`, `VSTUDIO_ROOT`, `SYSTEMDRIVE` (needed by vswhere to locate the VS installer instance database), `SYSTEMROOT` (needed by COM to load system DLLs), and `USERPROFILE` (needed by git to fetch repositories). Explicitly set `GOCACHE` in `tools/bazel[.bat]`: on Linux, Go derives `GOCACHE` from `XDG_CACHE_HOME` so unsetting it was fine; macOS does not honour XDG, so strict repo env (which strips `HOME`) exposed the gap. On Windows, `GOCACHE` was already set in the XDG branch but via `%XDG_CACHE_HOME%` (parse-time expansion) rather than `!XDG_CACHE_HOME!` (delayed), yielding a path with forward slashes before `XDG_CACHE_HOME` was normalised. Add an else branch to `tools/bazel[.bat]` forwarding `GOCACHE` and `GOMODCACHE` to their official defaults when `XDG_CACHE_HOME` is absent, so repo rules always receive non-empty values for both. Drop null environment overrides (`"GOPATH": None` from both `go_fast` and `go_sdk_overrides`, `"GOROOT": None` from `go_sdk_overrides` only): the flag already strips these from the repo-rule environment, making explicit unsetting redundant. Switch `_get_vs_property()` in `visual_studio.bzl` from `ctx.execute()` to `repo_utils.execute_checked()`, fixing a pre-existing `fail()` format bug and including stdout+stderr in error output automatically. Remove the `ANDROID_HOME` workaround from `tools/bazel[.bat]` (#49125), whose commit message identified this flag as the intended fix. ### Motivation Without this flag, any variable set on the host leaks silently into repository rules, causing non-reproducible builds and cross-platform divergence. The ANDROID_HOME issue (rules_android generating a full @AndroidSDK repo referencing the Bazel-9-removed CcInfo global) is one concrete instance; GOMODCACHE leaking into go_fast is another. ### Describe how you validated your changes CI. ### Additional Notes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
### What does this PR do? Add `--experimental_strict_repo_env` (bazelbuild/bazel#28189): only PATH (and PATHEXT on Windows) plus variables explicitly forwarded via `--repo_env` are now visible to repository rules. Drop `--incompatible_strict_action_env`, which graduated to the default in Bazel 9. Forward `GOCACHE`, `GOMODCACHE`, and `XDG_CACHE_HOME` to all platforms via `--repo_env`. Forward `DEPLOY_AGENT`, `FORCED_PACKAGE_COMPRESSION_LEVEL`, `PACKAGE_VERSION`, and `SIGN_MAC` so that `@agent_volatile//:env_vars.bzl` continues to see them (they are read at Starlark load time and cannot be replaced with build flags). On Windows, also forward `PIP_CACHE_DIR`, `VSTUDIO_ROOT`, `SYSTEMDRIVE` (needed by vswhere to locate the VS installer instance database), `SYSTEMROOT` (needed by COM to load system DLLs), and `USERPROFILE` (needed by git to fetch repositories). Explicitly set `GOCACHE` in `tools/bazel[.bat]`: on Linux, Go derives `GOCACHE` from `XDG_CACHE_HOME` so unsetting it was fine; macOS does not honour XDG, so strict repo env (which strips `HOME`) exposed the gap. On Windows, `GOCACHE` was already set in the XDG branch but via `%XDG_CACHE_HOME%` (parse-time expansion) rather than `!XDG_CACHE_HOME!` (delayed), yielding a path with forward slashes before `XDG_CACHE_HOME` was normalised. Add an else branch to `tools/bazel[.bat]` forwarding `GOCACHE` and `GOMODCACHE` to their official defaults when `XDG_CACHE_HOME` is absent, so repo rules always receive non-empty values for both. Drop null environment overrides (`"GOPATH": None` from both `go_fast` and `go_sdk_overrides`, `"GOROOT": None` from `go_sdk_overrides` only): the flag already strips these from the repo-rule environment, making explicit unsetting redundant. Switch `_get_vs_property()` in `visual_studio.bzl` from `ctx.execute()` to `repo_utils.execute_checked()`, fixing a pre-existing `fail()` format bug and including stdout+stderr in error output automatically. Remove the `ANDROID_HOME` workaround from `tools/bazel[.bat]` (#49125), whose commit message identified this flag as the intended fix. ### Motivation Without this flag, any variable set on the host leaks silently into repository rules, causing non-reproducible builds and cross-platform divergence. The ANDROID_HOME issue (rules_android generating a full @AndroidSDK repo referencing the Bazel-9-removed CcInfo global) is one concrete instance; GOMODCACHE leaking into go_fast is another. ### Describe how you validated your changes CI. ### Additional Notes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
### What does this PR do? Add `--experimental_strict_repo_env` (bazelbuild/bazel#28189): only PATH (and PATHEXT on Windows) plus variables explicitly forwarded via `--repo_env` are now visible to repository rules. Drop `--incompatible_strict_action_env`, which graduated to the default in Bazel 9. Forward `GOCACHE`, `GOMODCACHE`, and `XDG_CACHE_HOME` to all platforms via `--repo_env`. Forward `DEPLOY_AGENT`, `FORCED_PACKAGE_COMPRESSION_LEVEL`, `PACKAGE_VERSION`, and `SIGN_MAC` so that `@agent_volatile//:env_vars.bzl` continues to see them (they are read at Starlark load time and cannot be replaced with build flags). On Windows, also forward `PIP_CACHE_DIR`, `VSTUDIO_ROOT`, `SYSTEMDRIVE` (needed by vswhere to locate the VS installer instance database), `SYSTEMROOT` (needed by COM to load system DLLs), and `USERPROFILE` (needed by git to fetch repositories). Explicitly set `GOCACHE` in `tools/bazel[.bat]`: on Linux, Go derives `GOCACHE` from `XDG_CACHE_HOME` so unsetting it was fine; macOS does not honour XDG, so strict repo env (which strips `HOME`) exposed the gap. On Windows, `GOCACHE` was already set in the XDG branch but via `%XDG_CACHE_HOME%` (parse-time expansion) rather than `!XDG_CACHE_HOME!` (delayed), yielding a path with forward slashes before `XDG_CACHE_HOME` was normalised. Add an else branch to `tools/bazel[.bat]` forwarding `GOCACHE` and `GOMODCACHE` to their official defaults when `XDG_CACHE_HOME` is absent, so repo rules always receive non-empty values for both. Drop null environment overrides (`"GOPATH": None` from both `go_fast` and `go_sdk_overrides`, `"GOROOT": None` from `go_sdk_overrides` only): the flag already strips these from the repo-rule environment, making explicit unsetting redundant. Switch `_get_vs_property()` in `visual_studio.bzl` from `ctx.execute()` to `repo_utils.execute_checked()`, fixing a pre-existing `fail()` format bug and including stdout+stderr in error output automatically. Remove the `ANDROID_HOME` workaround from `tools/bazel[.bat]` (#49125), whose commit message identified this flag as the intended fix. ### Motivation Without this flag, any variable set on the host leaks silently into repository rules, causing non-reproducible builds and cross-platform divergence. The ANDROID_HOME issue (rules_android generating a full @AndroidSDK repo referencing the Bazel-9-removed CcInfo global) is one concrete instance; GOMODCACHE leaking into go_fast is another. ### Describe how you validated your changes CI. ### Additional Notes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
### What does this PR do? Add `--experimental_strict_repo_env` (bazelbuild/bazel#28189): only PATH (and PATHEXT on Windows) plus variables explicitly forwarded via `--repo_env` are now visible to repository rules. Drop `--incompatible_strict_action_env`, which graduated to the default in Bazel 9. Forward `GOCACHE`, `GOMODCACHE`, and `XDG_CACHE_HOME` to all platforms via `--repo_env`. Forward `DEPLOY_AGENT`, `FORCED_PACKAGE_COMPRESSION_LEVEL`, `PACKAGE_VERSION`, and `SIGN_MAC` so that `@agent_volatile//:env_vars.bzl` continues to see them (they are read at Starlark load time and cannot be replaced with build flags). On Windows, also forward `PIP_CACHE_DIR`, `VSTUDIO_ROOT`, `SYSTEMDRIVE` (needed by vswhere to locate the VS installer instance database), `SYSTEMROOT` (needed by COM to load system DLLs), and `USERPROFILE` (needed by git to fetch repositories). Explicitly set `GOCACHE` in `tools/bazel[.bat]`: on Linux, Go derives `GOCACHE` from `XDG_CACHE_HOME` so unsetting it was fine; macOS does not honour XDG, so strict repo env (which strips `HOME`) exposed the gap. On Windows, `GOCACHE` was already set in the XDG branch but via `%XDG_CACHE_HOME%` (parse-time expansion) rather than `!XDG_CACHE_HOME!` (delayed), yielding a path with forward slashes before `XDG_CACHE_HOME` was normalised. Add an else branch to `tools/bazel[.bat]` forwarding `GOCACHE` and `GOMODCACHE` to their official defaults when `XDG_CACHE_HOME` is absent, so repo rules always receive non-empty values for both. Drop null environment overrides (`"GOPATH": None` from both `go_fast` and `go_sdk_overrides`, `"GOROOT": None` from `go_sdk_overrides` only): the flag already strips these from the repo-rule environment, making explicit unsetting redundant. Switch `_get_vs_property()` in `visual_studio.bzl` from `ctx.execute()` to `repo_utils.execute_checked()`, fixing a pre-existing `fail()` format bug and including stdout+stderr in error output automatically. Remove the `ANDROID_HOME` workaround from `tools/bazel[.bat]` (#49125), whose commit message identified this flag as the intended fix. ### Motivation Without this flag, any variable set on the host leaks silently into repository rules, causing non-reproducible builds and cross-platform divergence. The ANDROID_HOME issue (rules_android generating a full @AndroidSDK repo referencing the Bazel-9-removed CcInfo global) is one concrete instance; GOMODCACHE leaking into go_fast is another. ### Describe how you validated your changes CI. ### Additional Notes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
### What does this PR do? Add `--experimental_strict_repo_env` (bazelbuild/bazel#28189): only PATH (and PATHEXT on Windows) plus variables explicitly forwarded via `--repo_env` are now visible to repository rules. Drop `--incompatible_strict_action_env`, which graduated to the default in Bazel 9. Forward `GOCACHE`, `GOMODCACHE`, and `XDG_CACHE_HOME` to all platforms via `--repo_env`. Forward `DEPLOY_AGENT`, `FORCED_PACKAGE_COMPRESSION_LEVEL`, `PACKAGE_VERSION`, and `SIGN_MAC` so that `@agent_volatile//:env_vars.bzl` continues to see them (they are read at Starlark load time and cannot be replaced with build flags). On Windows, also forward `PIP_CACHE_DIR`, `VSTUDIO_ROOT`, `SYSTEMDRIVE` (needed by vswhere to locate the VS installer instance database), `SYSTEMROOT` (needed by COM to load system DLLs), and `USERPROFILE` (needed by git to fetch repositories). Explicitly set `GOCACHE` in `tools/bazel[.bat]`: on Linux, Go derives `GOCACHE` from `XDG_CACHE_HOME` so unsetting it was fine; macOS does not honour XDG, so strict repo env (which strips `HOME`) exposed the gap. On Windows, `GOCACHE` was already set in the XDG branch but via `%XDG_CACHE_HOME%` (parse-time expansion) rather than `!XDG_CACHE_HOME!` (delayed), yielding a path with forward slashes before `XDG_CACHE_HOME` was normalised. Add an else branch to `tools/bazel[.bat]` forwarding `GOCACHE` and `GOMODCACHE` to their official defaults when `XDG_CACHE_HOME` is absent, so repo rules always receive non-empty values for both. Drop null environment overrides (`"GOPATH": None` from both `go_fast` and `go_sdk_overrides`, `"GOROOT": None` from `go_sdk_overrides` only): the flag already strips these from the repo-rule environment, making explicit unsetting redundant. Switch `_get_vs_property()` in `visual_studio.bzl` from `ctx.execute()` to `repo_utils.execute_checked()`, fixing a pre-existing `fail()` format bug and including stdout+stderr in error output automatically. Remove the `ANDROID_HOME` workaround from `tools/bazel[.bat]` (#49125), whose commit message identified this flag as the intended fix. ### Motivation Without this flag, any variable set on the host leaks silently into repository rules, causing non-reproducible builds and cross-platform divergence. The ANDROID_HOME issue (rules_android generating a full @AndroidSDK repo referencing the Bazel-9-removed CcInfo global) is one concrete instance; GOMODCACHE leaking into go_fast is another. ### Describe how you validated your changes CI. ### Additional Notes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
### What does this PR do? Add `--experimental_strict_repo_env` (bazelbuild/bazel#28189): only PATH (and PATHEXT on Windows) plus variables explicitly forwarded via `--repo_env` are now visible to repository rules. Drop `--incompatible_strict_action_env`, which graduated to the default in Bazel 9. Forward `GOCACHE`, `GOMODCACHE`, and `XDG_CACHE_HOME` to all platforms via `--repo_env`. Forward `DEPLOY_AGENT`, `FORCED_PACKAGE_COMPRESSION_LEVEL`, `PACKAGE_VERSION`, and `SIGN_MAC` so that `@agent_volatile//:env_vars.bzl` continues to see them (they are read at Starlark load time and cannot be replaced with build flags). On Windows, also forward `PIP_CACHE_DIR`, `VSTUDIO_ROOT`, `SYSTEMDRIVE` (needed by vswhere to locate the VS installer instance database), `SYSTEMROOT` (needed by COM to load system DLLs), and `USERPROFILE` (needed by git to fetch repositories). Explicitly set `GOCACHE` in `tools/bazel[.bat]`: on Linux, Go derives `GOCACHE` from `XDG_CACHE_HOME` so unsetting it was fine; macOS does not honour XDG, so strict repo env (which strips `HOME`) exposed the gap. On Windows, `GOCACHE` was already set in the XDG branch but via `%XDG_CACHE_HOME%` (parse-time expansion) rather than `!XDG_CACHE_HOME!` (delayed), yielding a path with forward slashes before `XDG_CACHE_HOME` was normalised. Add an else branch to `tools/bazel[.bat]` forwarding `GOCACHE` and `GOMODCACHE` to their official defaults when `XDG_CACHE_HOME` is absent, so repo rules always receive non-empty values for both. Drop null environment overrides (`"GOPATH": None` from both `go_fast` and `go_sdk_overrides`, `"GOROOT": None` from `go_sdk_overrides` only): the flag already strips these from the repo-rule environment, making explicit unsetting redundant. Switch `_get_vs_property()` in `visual_studio.bzl` from `ctx.execute()` to `repo_utils.execute_checked()`, fixing a pre-existing `fail()` format bug and including stdout+stderr in error output automatically. Remove the `ANDROID_HOME` workaround from `tools/bazel[.bat]` (#49125), whose commit message identified this flag as the intended fix. ### Motivation Without this flag, any variable set on the host leaks silently into repository rules, causing non-reproducible builds and cross-platform divergence. The ANDROID_HOME issue (rules_android generating a full @AndroidSDK repo referencing the Bazel-9-removed CcInfo global) is one concrete instance; GOMODCACHE leaking into go_fast is another. ### Describe how you validated your changes CI. ### Additional Notes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
### What does this PR do? Add `--experimental_strict_repo_env` (bazelbuild/bazel#28189): only PATH (and PATHEXT on Windows) plus variables explicitly forwarded via `--repo_env` are now visible to repository rules. Drop `--incompatible_strict_action_env`, which graduated to the default in Bazel 9. Forward `GOCACHE`, `GOMODCACHE`, and `XDG_CACHE_HOME` to all platforms via `--repo_env`. Forward `DEPLOY_AGENT`, `FORCED_PACKAGE_COMPRESSION_LEVEL`, `PACKAGE_VERSION`, and `SIGN_MAC` so that `@agent_volatile//:env_vars.bzl` continues to see them (they are read at Starlark load time and cannot be replaced with build flags). On Windows, also forward `PIP_CACHE_DIR`, `VSTUDIO_ROOT`, `SYSTEMDRIVE` (needed by vswhere to locate the VS installer instance database), `SYSTEMROOT` (needed by COM to load system DLLs), and `USERPROFILE` (needed by git to fetch repositories). Explicitly set `GOCACHE` in `tools/bazel[.bat]`: on Linux, Go derives `GOCACHE` from `XDG_CACHE_HOME` so unsetting it was fine; macOS does not honour XDG, so strict repo env (which strips `HOME`) exposed the gap. On Windows, `GOCACHE` was already set in the XDG branch but via `%XDG_CACHE_HOME%` (parse-time expansion) rather than `!XDG_CACHE_HOME!` (delayed), yielding a path with forward slashes before `XDG_CACHE_HOME` was normalised. Add an else branch to `tools/bazel[.bat]` forwarding `GOCACHE` and `GOMODCACHE` to their official defaults when `XDG_CACHE_HOME` is absent, so repo rules always receive non-empty values for both. Drop null environment overrides (`"GOPATH": None` from both `go_fast` and `go_sdk_overrides`, `"GOROOT": None` from `go_sdk_overrides` only): the flag already strips these from the repo-rule environment, making explicit unsetting redundant. Switch `_get_vs_property()` in `visual_studio.bzl` from `ctx.execute()` to `repo_utils.execute_checked()`, fixing a pre-existing `fail()` format bug and including stdout+stderr in error output automatically. Remove the `ANDROID_HOME` workaround from `tools/bazel[.bat]` (#49125), whose commit message identified this flag as the intended fix. ### Motivation Without this flag, any variable set on the host leaks silently into repository rules, causing non-reproducible builds and cross-platform divergence. The ANDROID_HOME issue (rules_android generating a full @AndroidSDK repo referencing the Bazel-9-removed CcInfo global) is one concrete instance; GOMODCACHE leaking into go_fast is another. ### Describe how you validated your changes CI. ### Additional Notes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
### What does this PR do? Add `--experimental_strict_repo_env` (bazelbuild/bazel#28189): only PATH (and PATHEXT on Windows) plus variables explicitly forwarded via `--repo_env` are now visible to repository rules. Drop `--incompatible_strict_action_env`, which graduated to the default in Bazel 9. Forward `GOCACHE`, `GOMODCACHE`, and `XDG_CACHE_HOME` to all platforms via `--repo_env`. Forward `DEPLOY_AGENT`, `FORCED_PACKAGE_COMPRESSION_LEVEL`, `PACKAGE_VERSION`, and `SIGN_MAC` so that `@agent_volatile//:env_vars.bzl` continues to see them (they are read at Starlark load time and cannot be replaced with build flags). On Windows, also forward `PIP_CACHE_DIR`, `VSTUDIO_ROOT`, `SYSTEMDRIVE` (needed by vswhere to locate the VS installer instance database), `SYSTEMROOT` (needed by COM to load system DLLs), and `USERPROFILE` (needed by git to fetch repositories). Explicitly set `GOCACHE` in `tools/bazel[.bat]`: on Linux, Go derives `GOCACHE` from `XDG_CACHE_HOME` so unsetting it was fine; macOS does not honour XDG, so strict repo env (which strips `HOME`) exposed the gap. On Windows, `GOCACHE` was already set in the XDG branch but via `%XDG_CACHE_HOME%` (parse-time expansion) rather than `!XDG_CACHE_HOME!` (delayed), yielding a path with forward slashes before `XDG_CACHE_HOME` was normalised. Add an else branch to `tools/bazel[.bat]` forwarding `GOCACHE` and `GOMODCACHE` to their official defaults when `XDG_CACHE_HOME` is absent, so repo rules always receive non-empty values for both. Drop null environment overrides (`"GOPATH": None` from both `go_fast` and `go_sdk_overrides`, `"GOROOT": None` from `go_sdk_overrides` only): the flag already strips these from the repo-rule environment, making explicit unsetting redundant. Switch `_get_vs_property()` in `visual_studio.bzl` from `ctx.execute()` to `repo_utils.execute_checked()`, fixing a pre-existing `fail()` format bug and including stdout+stderr in error output automatically. Remove the `ANDROID_HOME` workaround from `tools/bazel[.bat]` (#49125), whose commit message identified this flag as the intended fix. ### Motivation Without this flag, any variable set on the host leaks silently into repository rules, causing non-reproducible builds and cross-platform divergence. The ANDROID_HOME issue (rules_android generating a full @AndroidSDK repo referencing the Bazel-9-removed CcInfo global) is one concrete instance; GOMODCACHE leaking into go_fast is another. ### Describe how you validated your changes CI. ### Additional Notes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
### What does this PR do? Add `--experimental_strict_repo_env` (bazelbuild/bazel#28189): only PATH (and PATHEXT on Windows) plus variables explicitly forwarded via `--repo_env` are now visible to repository rules. Drop `--incompatible_strict_action_env`, which graduated to the default in Bazel 9 (bazelbuild/bazel#27670). Forward `GOCACHE`, `GOMODCACHE`, and `XDG_CACHE_HOME` to all platforms via `--repo_env`, as well as `Environment values available for packaging`: https://github.com/DataDog/datadog-agent/blob/fa38b7e14170db0f6bfed0208493b76916c04731/MODULE.bazel#L7-L23 On Windows, also forward `PIP_CACHE_DIR`, `VSTUDIO_ROOT`, `SYSTEMDRIVE` (needed by vswhere to locate the VS installer instance database), `SYSTEMROOT` (needed by COM to load system DLLs), and `USERPROFILE` (needed by git to fetch repositories). Explicitly set `GOCACHE` in `tools/bazel[.bat]`: - on Linux, Go derives `GOCACHE` from `XDG_CACHE_HOME` so having it unset or set to the same derived value is **neutral**, - on macOS, Go doesn't happen to honor XDG yet, so strict `repo_env` (which strips `HOME`) exposed the gap, which is now **fixed**, - on Windows, `GOCACHE` was already set in the XDG branch but via `%XDG_CACHE_HOME%` (parse-time expansion) rather than `!XDG_CACHE_HOME!` (delayed), yielding a path with forward slashes before `XDG_CACHE_HOME` was normalised - also **fixed**. When `XDG_CACHE_HOME` is absent, forward `GOCACHE` and `GOMODCACHE` (to their official defaults unless explicitly set at user's discretion), so Go repo rules always receive non-empty values for both. What's mentioned above allows to drop null environment overrides (`"GOPATH": None` from both `go_fast` and `go_sdk_overrides`, `"GOROOT": None` from `go_sdk_overrides` only): the flag already strips these from the repo-rule environment, making explicit unsetting redundant. Switch `_get_vs_property()` in `visual_studio.bzl` from `ctx.execute()` to `repo_utils.execute_checked()`, which: - fixes a pre-existing `fail()` format bug, - includes `stdout` in the error message automatically (`vswhere` prints to it), - overall brings a more actionable error output. Finally, remove the `ANDROID_HOME` workaround from `tools/bazel[.bat]` (follow-up of #49125). ### Motivation Without this flag, any variable set on the host leaks silently into repository rules, causing non-reproducible builds and cross-platform divergence, leading to adhoc fixes like bazelbuild/bazel#27670 or bazelbuild/bazel#28189. We don't want that to happen again which means no variables other than explicitly allow-listed should spuriously alter repositories rules. :bulb: Users still have the option to pass additional `--repo_env` parameters to `bazel` on their end should they need: corporate proxy, etc. ### Describe how you validated your changes - local Windows VM, - CI. ### Additional Notes - bazelbuild/bazel#27670 - bazelbuild/bazel#28189 - #48032 - #49125 Co-authored-by: regis.desgroppes <regis.desgroppes@datadoghq.com>
### What does this PR do? Add `--experimental_strict_repo_env` (bazelbuild/bazel#28189): only PATH (and PATHEXT on Windows) plus variables explicitly forwarded via `--repo_env` are now visible to repository rules. Drop `--incompatible_strict_action_env`, which graduated to the default in Bazel 9 (bazelbuild/bazel#27670). Forward `GOCACHE`, `GOMODCACHE`, and `XDG_CACHE_HOME` to all platforms via `--repo_env`, as well as `Environment values available for packaging`: https://github.com/DataDog/datadog-agent/blob/fa38b7e14170db0f6bfed0208493b76916c04731/MODULE.bazel#L7-L23 On Windows, also forward `PIP_CACHE_DIR`, `VSTUDIO_ROOT`, `SYSTEMDRIVE` (needed by vswhere to locate the VS installer instance database), `SYSTEMROOT` (needed by COM to load system DLLs), and `USERPROFILE` (needed by git to fetch repositories). Explicitly set `GOCACHE` in `tools/bazel[.bat]`: - on Linux, Go derives `GOCACHE` from `XDG_CACHE_HOME` so having it unset or set to the same derived value is **neutral**, - on macOS, Go doesn't happen to honor XDG yet, so strict `repo_env` (which strips `HOME`) exposed the gap, which is now **fixed**, - on Windows, `GOCACHE` was already set in the XDG branch but via `%XDG_CACHE_HOME%` (parse-time expansion) rather than `!XDG_CACHE_HOME!` (delayed), yielding a path with forward slashes before `XDG_CACHE_HOME` was normalised - also **fixed**. When `XDG_CACHE_HOME` is absent, forward `GOCACHE` and `GOMODCACHE` (to their official defaults unless explicitly set at user's discretion), so Go repo rules always receive non-empty values for both. What's mentioned above allows to drop null environment overrides (`"GOPATH": None` from both `go_fast` and `go_sdk_overrides`, `"GOROOT": None` from `go_sdk_overrides` only): the flag already strips these from the repo-rule environment, making explicit unsetting redundant. Switch `_get_vs_property()` in `visual_studio.bzl` from `ctx.execute()` to `repo_utils.execute_checked()`, which: - fixes a pre-existing `fail()` format bug, - includes `stdout` in the error message automatically (`vswhere` prints to it), - overall brings a more actionable error output. Finally, remove the `ANDROID_HOME` workaround from `tools/bazel[.bat]` (follow-up of #49125). ### Motivation Without this flag, any variable set on the host leaks silently into repository rules, causing non-reproducible builds and cross-platform divergence, leading to adhoc fixes like bazelbuild/bazel#27670 or bazelbuild/bazel#28189. We don't want that to happen again which means no variables other than explicitly allow-listed should spuriously alter repositories rules. :bulb: Users still have the option to pass additional `--repo_env` parameters to `bazel` on their end should they need: corporate proxy, etc. ### Describe how you validated your changes - local Windows VM, - CI. ### Additional Notes - bazelbuild/bazel#27670 - bazelbuild/bazel#28189 - #48032 - #49125 Co-authored-by: regis.desgroppes <regis.desgroppes@datadoghq.com>
What does this PR do?
Unsets
ANDROID_HOMEintools/bazel*hooks right before invokingbazel.Motivation
We transitively depend on
rules_android0.6.4 that looks for$ANDROID_HOMEto locate an Android SDK.GitHub Actions ubuntu-24.04 runners have one (partially?) installed, so the
android_sdk_repository_extensiongenerates a full@androidsdkrepo that loadshelper.bzl, which transitively referencesCcInfoas abazelglobal.That global was removed in
bazel9, causing analysis to fail at times with:(https://github.com/DataDog/datadog-agent/actions/runs/24135010393/job/70420742307#step:11:1684)
Unsetting
ANDROID_HOMEcauses the extension to generate a stub repo instead, with noCcInforeference.Describe how you validated your changes
Reproduced locally with:
Command fails without the fix, succeeds with it.
Additional Notes
The proper long-term fix is
--experimental_strict_repo_env, which will prevent repo rules from reading undeclared environment variables:bazel's strictrepo_env#48713.