Where to get list of known repositories like @bazel_tools, @rules_jvm_external etc?

Viewed 2070

Sometimes I see extensions loading from the internet or built-in ones. Canonical example:

load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

However, I cannot distinguish local repo and known repo by looking at the load expression.

How can I check the source (location) of any repo which I see in my WORKSPACE/BUILD files?

3 Answers

bazel query --output=build //external:repo_name works just fine.

If the Bazel label is sufficient as a source, you might try fetching repo roots with BUILD files with bazel query 'buildfiles(//...)'.

Otherwise, you could run bazel clean --expunge and run a build with --experimental_execution_log_file=<FILENAME>. This creates a protobuf based log of the actions by Bazel. In there, all internet repos are downloaded anew because of clean --expunge.

Check https://github.com/bazelbuild/bazel/tree/master/src/tools/execlog for a parser.

It is super inconvenient that this information is not available another way - afaik. I really hope someone swings by and corrects me, but this way you at least know the available sources you can correlate.

I'm new to Bazel, but as far as I understand:

  • Copy the name of the repo. E.g. io_bazel_rules_docker
  • Search it through the codebase
  • Look at how it's being loaded

E.g. if you see

http_archive(
    name = "io_bazel_rules_docker",
    ...
)
http_file(
    name = "io_bazel_rules_docker",
    ...
)

And you can conclude where it's coming from.

Related