new_local_repository fails when repo contains a BUILD file #24770
Labels
team-ExternalDeps
External dependency handling, remote repositiories, WORKSPACE file.
type: bug
untriaged
Description of the bug:
When using
new_local_repository
withbuild_file
if the repository being pointed to contains a BUILD.bazel file, bazel will error out with the message below. I would expect the build filed referenced bybuild_file
be used in this case, as happened in bazel 6.5.0.If
build_file_content
is used instead ofbuild_file
, bazel succeeds.Which category does this issue belong to?
External Dependency
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Follow the steps in https://github.com/davexroth/bazel_repo_build_overwrite_repro to reproduce.
Which operating system are you running Bazel on?
Linux
What is the output of
bazel info release
?release 8.0.0
If
bazel info release
returnsdevelopment version
or(@non-git)
, tell us how you built Bazel.No response
What's the output of
git remote get-url origin; git rev-parse HEAD
?No response
If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.
Yes. bazel 6.5.0 works, but 7.4.1 and 8.0.0 fail.
Have you found anything relevant by searching the web?
#1697
Any other information, logs, or outputs that you want to share?
INFO: Repository +_repo_rules+file instantiated at:
: in
Repository rule new_local_repository defined at:
/usr/local/google/home/davidroth/.cache/bazel/_bazel_davidroth/77517e29f413fe65e1499ca70ade7700/external/bazel_tools/tools/build_defs/repo/local.bzl:103:39: in
ERROR: /usr/local/google/home/davidroth/.cache/bazel/_bazel_davidroth/77517e29f413fe65e1499ca70ade7700/external/bazel_tools/tools/build_defs/repo/local.bzl:55:13: An error occurred during the fetch of repository '+_repo_rules+file':
Traceback (most recent call last):
File "/usr/local/google/home/davidroth/.cache/bazel/_bazel_davidroth/77517e29f413fe65e1499ca70ade7700/external/bazel_tools/tools/build_defs/repo/local.bzl", line 86, column 29, in _new_local_repository_impl
children = _get_dir_path(rctx).readdir()
File "/usr/local/google/home/davidroth/.cache/bazel/_bazel_davidroth/77517e29f413fe65e1499ca70ade7700/external/bazel_tools/tools/build_defs/repo/local.bzl", line 55, column 13, in _get_dir_path
fail(
Error in fail: The repository's path is "external/file" (absolute: "/usr/local/google/home/davidroth/GitHub/davexroth/bazel_repo_build_overwrite_repro/external/file") but it does not exist or is not a directory.
ERROR: no such package '@@+_repo_rules+file//': The repository's path is "external/file" (absolute: "/usr/local/google/home/davidroth/GitHub/davexroth/bazel_repo_build_overwrite_repro/external/file") but it does not exist or is not a directory.
ERROR: /usr/local/google/home/davidroth/GitHub/davexroth/bazel_repo_build_overwrite_repro/BUILD.bazel:9:10: //:file depends on @@+_repo_rules+file//:a in repository @@+_repo_rules+file which failed to fetch. no such package '@@+_repo_rules+file//': The repository's path is "external/file" (absolute: "/usr/local/google/home/davidroth/GitHub/davexroth/bazel_repo_build_overwrite_repro/external/file") but it does not exist or is not a directory.
ERROR: Analysis of target '//:file' failed; build aborted: Analysis failed
INFO: Elapsed time: 0.205s, Critical Path: 0.01s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
The text was updated successfully, but these errors were encountered: