From c427e3432e89cd6abb53f15dd9fe40bb4b3e7b30 Mon Sep 17 00:00:00 2001 From: "bazel.build machine account" Date: Tue, 14 Jan 2025 11:10:18 +0100 Subject: [PATCH] [7.5.0] Remove BUILD.bazel before symlinking when creating new_local_repository (#24900) Fixes #24770 Closes #24887. PiperOrigin-RevId: 714107497 Change-Id: Ib914aa54b2afa2a90fcce2f2263b9c1b2d2c193c Commit https://github.com/bazelbuild/bazel/commit/6a141eab3fa5d57eb8b5dadbb6260a120c597fe9 Co-authored-by: Dave Roth --- tools/build_defs/repo/local.bzl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/build_defs/repo/local.bzl b/tools/build_defs/repo/local.bzl index 69e0c1ae0b98a5..67da117c421c05 100644 --- a/tools/build_defs/repo/local.bzl +++ b/tools/build_defs/repo/local.bzl @@ -94,6 +94,9 @@ def _new_local_repository_impl(rctx): rctx.watch(child) if rctx.attr.build_file != None: + # Remove any existing BUILD.bazel in the repository to ensure + # the symlink to the defined build_file doesn't fail. + rctx.delete("BUILD.bazel") rctx.symlink(rctx.attr.build_file, "BUILD.bazel") if rctx.os.name.startswith("windows"): rctx.watch(rctx.attr.build_file) # same reason as above