-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new_local_repository fails when repo contains a BUILD file #24770
Comments
We should probably delete |
The problem here is that you're specifying This should always have been failing, by the way; with your reproducer, I get almost exactly the same failure on 6.5.0 too:
|
This shouldn't be necessary, as |
Sorry for the confusion, I somehow didn't include the I've verified again, and 6.5.0, but 7.4.1 and 8.0.0 fail. |
Thanks, now the bug is evident -- very close to where Yun linked above, we should delete the existing BUILD.bazel file when we introduce a symlink (so https://cs.opensource.google/bazel/bazel/+/master:tools/build_defs/repo/local.bzl;drc=33775c9e0d78a821aecbed96d3c1dec222a754dc;l=97). This should be very easy to fix. |
@davexroth Are you willing to give it a try to fix this? Our bandwidth is pretty limited but happy to review a PR! |
Sure thing. See linked PR. |
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: