budchan chao
budchan chao

Reputation: 327

Loading Bazel Extension Fails

I am trying to add an external dependency via a repository rule in my bazel build. I have the rule file in a separate directory and I was trying to load it in the root WORKSPACE file. The setup is as follows.

[root]/WORKSPACE

load("//thirdparty:myrepo.bzl", "my_repository")

my_repository(
    name = "myrepo",
)

[root]/thirdparty/myrepo.bzl

def _repository_impl(ctxt):

my_repository = repository_rule(
    implementation = _repository_impl,
    environ = ["CC", "CXX", "LD_LIBRARY_PATH"],
    local = True,
)

[root]/src/BUILD

cc_binary(
    name = "hello",
    srcs = [
        "hello.cc",
    ],
    deps = [
        "@myrepo//:foo"
    ],
)

But when I tried to build the hello target it fails with the following.

$ bazel build -c dbg //src:*
INFO: Invocation ID: d6b14442-0558-4c07-8414-59a0766ce338
ERROR: error loading package '': Unable to load package for '//thirdparty:myrepo.bzl': BUILD file not found on package path
ERROR: error loading package '': Unable to load package for '//thirdparty:myrepo.bzl': BUILD file not found on package path
INFO: Elapsed time: 1.217s

Why is it failing to find the extension (.bzl) file?

ps:

bazel version is 0.21.0

Upvotes: 0

Views: 1273

Answers (1)

ahumesky
ahumesky

Reputation: 5006

BUILD file not found on package path means that the label says there should be a BUILD file at that location (which creates a build package), but there wasn't one found.

Basically, I think all you need to do is create an empty BUILD file next to [root]/thirdparty/myrepo.bzl

Upvotes: 3

Related Questions