From fb21d42e46f291131426d526d52dc697ac714150 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Desgroppes?= Date: Thu, 26 Mar 2026 19:06:07 +0100 Subject: [PATCH] Make `gazelle` consider only `BUILD.bazel` files ### What does this PR do? Configure the `//:gazelle` target with `-build_file_name=BUILD.bazel`. ### Motivation When `gazelle` runs inside a Linux container on macOS via Docker Desktop, the workspace is typically mounted on a case-insensitive filesystem where `BUILD` and `build` are indistinguishable. This causes spurious errors such as: ```sh bazel run //:gazelle; echo $? ... gazelle: open /dda/.gitlab/windows/build: no such file or directory open /dda/rtloader/build: no such file or directory 1 ``` Whereas the cause strictly resides in a filesystem layer/driver (docker/desktop-feedback#251, recently imported from docker/for-mac#7218), portable tools have been taking countermeasures. Bazel 9, for instance, revamped their filesystem cache to better accomodate case-insensitive filesystems (bazelbuild/bazel#26842), which led us to switch to it (#47742), but that only covers Bazel's own I/O, not the processes it spawns, of which `gazelle`. For that purpose, Gazelle happens to explicitly recommend setting its `build_file_name` directive to `BUILD.bazel`: > If a repository contains files named `build` that aren't related to Bazel, it may help to set this to `"BUILD.bazel"`, especially on case-insensitive file systems. ### Additional Notes For consistency with the narrowed scope, this change renames `compliance/rules/BUILD` to `compliance/rules/BUILD.bazel` (the only plain `BUILD` file still present in the tree). --- BUILD.bazel | 5 ++++- compliance/rules/{BUILD => BUILD.bazel} | 0 2 files changed, 4 insertions(+), 1 deletion(-) rename compliance/rules/{BUILD => BUILD.bazel} (100%) diff --git a/BUILD.bazel b/BUILD.bazel index bb1f754c702efb..2bbfb15987643b 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -446,7 +446,10 @@ ALL_BUILD_TAGS = [ # gazelle:prefix github.com/DataDog/datadog-agent gazelle( name = "gazelle", - args = ["-external=static"], # don't use the network: https://github.com/bazel-contrib/bazel-gazelle/issues/1385 + args = [ + "-build_file_name=BUILD.bazel", # avoid BUILD/build mess: https://github.com/docker/desktop-feedback/issues/251 + "-external=static", # don't use the network: https://github.com/bazel-contrib/bazel-gazelle/issues/1385 + ], build_tags = ALL_BUILD_TAGS, gazelle = ":gazelle_binary", ) diff --git a/compliance/rules/BUILD b/compliance/rules/BUILD.bazel similarity index 100% rename from compliance/rules/BUILD rename to compliance/rules/BUILD.bazel