-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Description
Description of the bug:
When using new_local_repository with build_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 by build_file be used in this case, as happened in bazel 6.5.0.
If build_file_content is used instead of build_file, bazel succeeds.
INFO: Repository +_repo_rules+file instantiated at:
<builtin>: in <toplevel>
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 <toplevel>
ERROR: /usr/local/google/home/davidroth/.cache/bazel/_bazel_davidroth/77517e29f413fe65e1499ca70ade7700/external/bazel_tools/tools/build_defs/repo/local.bzl:97:21: 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 97, column 21, in _new_local_repository_impl
rctx.symlink(rctx.attr.build_file, "BUILD.bazel")
Error in symlink: java.io.IOException: Could not create symlink from /usr/local/google/home/davidroth/GitHub/davexroth/bazel_repo_build_overwrite_repro/file.BUILD.bazel to /usr/local/google/home/davidroth/.cache/bazel/_bazel_davidroth/77517e29f413fe65e1499ca70ade7700/external/+_repo_rules+file/BUILD.bazel: /usr/local/google/home/davidroth/.cache/bazel/_bazel_davidroth/77517e29f413fe65e1499ca70ade7700/external/+_repo_rules+file/BUILD.bazel (File exists)
ERROR: no such package '@@+_repo_rules+file//': java.io.IOException: Could not create symlink from /usr/local/google/home/davidroth/GitHub/davexroth/bazel_repo_build_overwrite_repro/file.BUILD.bazel to /usr/local/google/home/davidroth/.cache/bazel/_bazel_davidroth/77517e29f413fe65e1499ca70ade7700/external/+_repo_rules+file/BUILD.bazel: /usr/local/google/home/davidroth/.cache/bazel/_bazel_davidroth/77517e29f413fe65e1499ca70ade7700/external/+_repo_rules+file/BUILD.bazel (File exists)
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//': java.io.IOException: Could not create symlink from /usr/local/google/home/davidroth/GitHub/davexroth/bazel_repo_build_overwrite_repro/file.BUILD.bazel to /usr/local/google/home/davidroth/.cache/bazel/_bazel_davidroth/77517e29f413fe65e1499ca70ade7700/external/+_repo_rules+file/BUILD.bazel: /usr/local/google/home/davidroth/.cache/bazel/_bazel_davidroth/77517e29f413fe65e1499ca70ade7700/external/+_repo_rules+file/BUILD.bazel (File exists)
ERROR: Analysis of target '//:file' failed; build aborted: Analysis failed
INFO: Elapsed time: 5.842s, Critical Path: 0.04s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
FAILED:
Fetching repository @@rules_cc++cc_configure_extension+local_config_cc; starting
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 returns development 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?
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