buildtools
buildtools copied to clipboard
buildifier_test target missing on latest release and master
It seems as though the latest release, and master are missing the buildifier_test
target when I add it as a target in my project using Bazel 4.1.0 on macOS 11.2.3 (x86)
In order to isolate the problem, I created a workspace with just the WORKSPACE and a BUILD.bazel file as follows:
load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier_test")
buildifier_test(
name = "buildifier_test",
)
Upon running the target bazel test //:buildifier_test
, I get the following errors (with my name redacted as [my-name]
):
[my-name]@[my-name]s-MacBook-Pro-2 buildifier-test % bazel test //:buildifier_test
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
INFO: SHA256 (https://github.com/protocolbuffers/protobuf/archive/master.zip) = 3093c29fcdc702b56aef93394ec3666fd90330214b63c81b28ab9249428f2eba
DEBUG: Rule 'com_google_protobuf' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = "3093c29fcdc702b56aef93394ec3666fd90330214b63c81b28ab9249428f2eba"
DEBUG: Repository com_google_protobuf instantiated at:
/Users/[my-name]/dev/buildifier-test/WORKSPACE:35:13: in <toplevel>
Repository rule http_archive defined at:
/private/var/tmp/_bazel_[my-name]/b0f816d90ad3499bead1f0595f38904b/external/bazel_tools/tools/build_defs/repo/http.bzl:336:31: in <toplevel>
ERROR: Traceback (most recent call last):
File "/Users/[my-name]/dev/buildifier-test/BUILD.bazel", line 1, column 64, in <toplevel>
load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier_test")
Error: file '@com_github_bazelbuild_buildtools//buildifier:def.bzl' does not contain symbol 'buildifier_test'
ERROR: Skipping '//:buildifier_test': no such target '//:buildifier_test': target 'buildifier_test' not declared in package '' defined by /Users/[my-name]/dev/buildifier-test/BUILD.bazel
ERROR: no such target '//:buildifier_test': target 'buildifier_test' not declared in package '' defined by /Users/[my-name]/dev/buildifier-test/BUILD.bazel
INFO: Elapsed time: 69.233s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (1 packages loaded)
FAILED: Build did NOT complete successfully (1 packages loaded)
Poking around in the cache, I found that the generated external/com_github_bazelbuild_buildtools/buildifier/def.bzl
, attached to this issue, does indeed not mention any _buildifier_test
.
Further, I've found that Gazelle seems to have brought in a much older version of the bazel/build repo at the following path:
external/bazel_gazelle_go_repository_cache/pkg/mod/github.com/bazelbuild/[email protected]/buildifier/def.bzl
In addition, there is a similarly named build target in b0f816d90ad3499bead1f0595f38904b/external/io_bazel_rules_go/tests/buildifier_test.bzl
I have included the mentioned files in their respective paths in the attached archive.
What is causing this absence of this target in my build?
@vladmos
The b0f816d90ad3499bead1f0595f38904b
hash is generated by bazel to refer to your workspace, and is not useful information here.
If you are still experiencing this, can you please provide the stanza you're using to fetch @com_github_bazelbuild_buildtools
that is defined in your WORKSPACE
file`?
My initial assumption is that rules_go
is defined before buildtools
, which means that you're using the version of buildtools
that rules_go
defines. If this is the case, you'll want to read the rules_go
documentation for overriding dependencies.
I think this can be closed. I was trying to get an overview of known issue in buildifier_test but I don't think that makes sense to keep this opened.