Skip to content

no such target '@@com_github_bazelbuild_buildtools//buildifier:runner.bat.template' #1259

@steve-261370

Description

@steve-261370

In #1011 support for windows was added. It added the new attribute label _windows_runner as follows:

https://github.com/bazelbuild/buildtools/blob/v7.1.0/buildifier/internal/factory.bzl#L83

        "_runner": attr.label(
            default = "//buildifier:runner.bash.template",
            allow_single_file = True,
        ),
        "_windows_runner": attr.label(
            default = "@com_github_bazelbuild_buildtools//buildifier:runner.bat.template",
            allow_single_file = True,
        ),

Notice how the default key for the _windows_runner attribute, references runner.bat.template by the external dependency @com_github_bazelbuild_buildtools but the other _runner refers to it with an absolute path.

default = "//buildifier:runner.bash.template",

vs

default = "@com_github_bazelbuild_buildtools//buildifier:runner.bat.template",


I use this project to configure a buildifier target in my own Bazel project:

load("@bazel_buildtools//buildifier:def.bzl", "buildifier")

buildifier(
    name = "buildifier",
)

But when I upgraded to the latest version, v7.1.0, the target now fails with:

ERROR: /home/steve-261370/.cache/bazel/_bazel_steve-261370/2914a5da309afa1aa83708b7e78fb71f/external/com_github_bazelbuild_buildtools/buildifier/BUILD.bazel: no such target '@@com_github_bazelbuild_buildtools//buildifier:runner.bat.template': target 'runner.bat.template' not declared in package 'buildifier' defined by /home/steve-261370/.cache/bazel/_bazel_steve-261370/2914a5da309afa1aa83708b7e78fb71f/external/com_github_bazelbuild_buildtools/buildifier/BUILD.bazel (did you mean runner.bash.template?)
ERROR: /home/steve-261370/my-bazel-project/BUILD.bazel:10:11: every rule of type _buildifier implicitly depends upon the target '@@com_github_bazelbuild_buildtools//buildifier:runner.bat.template', but this target could not be found because of: no such target '@@com_github_bazelbuild_buildtools//buildifier:runner.bat.template': target 'runner.bat.template' not declared in package 'buildifier' defined by /home/steve-261370/.cache/bazel/_bazel_steve-261370/2914a5da309afa1aa83708b7e78fb71f/external/com_github_bazelbuild_buildtools/buildifier/BUILD.bazel (did you mean runner.bash.template?)

I ended up fixing this by replacing the line:

default = "@com_github_bazelbuild_buildtools//buildifier:runner.bat.template",

with

default = "//buildifier:runner.bat.template",

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions