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
Starlark http_archive's build_file attribute is not relative to the main workspace #6225
Comments
build_file
is not relative to the main workspace
Yes, the reference should be |
Okay, but I note that like #5633, this behavior difference makes it wrong to advertise the It would be nice if the Starlark rules' documentation was online like the native rules they deprecate. |
I just gave this a try because I ran into the same issue. Even with
The only thing that works for me is to use |
Agreed that this is not a great error message @FabianHenneke, but what this line
tells you is that your root package (
fixes this. Filed #7457 for the error message. |
Thank you very much @dslomov .
It works!! I learned gtest example of bazel with cpp (https://docs.bazel.build/versions/master/cpp-use-cases.html) and encountered the following error: ERROR: An error occurred during the fetch of repository 'gtest':
Traceback (most recent call last):
File "/root/.cache/bazel/_bazel_root/f85ff975689f12813b75367d2f317669/external/bazel_tools/tools/build_defs/repo/http.bzl", line 60
workspace_and_buildfile(ctx)
File "/root/.cache/bazel/_bazel_root/f85ff975689f12813b75367d2f317669/external/bazel_tools/tools/build_defs/repo/utils.bzl", line 61, in workspace_and_buildfile
ctx.symlink(ctx.attr.build_file, "BUILD.bazel")
Unable to load package for //:gtest.BUILD: BUILD file not found in any of the following directories.
- /root/wkdir/learn/bazel/examples/cpp-tutorial/http
ERROR: /root/wkdir/learn/bazel/examples/cpp-tutorial/http/test/BUILD:1:1: //test:hello-test depends on @gtest//:main in repository @gtest which failed to fetch. no such package '@gtest//': Traceback (most recent call last):
File "/root/.cache/bazel/_bazel_root/f85ff975689f12813b75367d2f317669/external/bazel_tools/tools/build_defs/repo/http.bzl", line 60
workspace_and_buildfile(ctx)
File "/root/.cache/bazel/_bazel_root/f85ff975689f12813b75367d2f317669/external/bazel_tools/tools/build_defs/repo/utils.bzl", line 61, in workspace_and_buildfile
ctx.symlink(ctx.attr.build_file, "BUILD.bazel")
Unable to load package for //:gtest.BUILD: BUILD file not found in any of the following directories.
- /root/wkdir/learn/bazel/examples/cpp-tutorial/http
ERROR: Analysis of target '//test:hello-test' failed; build aborted: Analysis failed
INFO: Elapsed time: 0.065s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets configured)
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets configured)
|
new_http_archive
'sbuild_file
attribute is documented to be dereferenced relative to the main workspace root. Thus, the following example using the builtinnew_http_archive
rule works fine:However, it doesn't work with the Starlark
http_archive
:Is this difference intentional?
The text was updated successfully, but these errors were encountered: