Query the usage of third party repository rules

1,081 views
Skip to first unread message

Xiaoyi Shi

unread,
Aug 20, 2018, 6:11:47 AM8/20/18
to bazel-discuss
Hi all,

I've posted this question on SO for over a week, but so far there is no answer yet.  I'm forwarding it here to reach to a larger Bazel user group and hopefully, someone could point me some directions.


It has always been a pain in the ass to manage third party dependencies. In our monolith repo, there are over 70 third party repos introduced with repository rules (eg. go_repositorygit_repository, etc.)
Some repos are added as transitive dependencies. After upgrading some of the direct third party dependencies, some of the transitive dependencies became dangling links.
I've already tried the following:
$ bazel query 'somepath(//...,@REPO_NAME_IN_QUESTION//...)'
Which runs extremely slow, and I ended up with a quick grep in all build files -- as the repo rules are always started with "@".
I'm wondering if there is an easy way to query the dependency graph of all rules in external repositories.


Thanks!
Xiaoyi

Paul Johnston

unread,
Aug 27, 2018, 5:06:47 PM8/27/18
to bazel-discuss
I don't know a bazel query command to do what you are looking for in one shot, but `bazel query //external:*` is a handy trick to get all the external workspace names.  You could then write a shell script to do what you want, perhaps using genquery to be fancy.

HTH,
Paul

Paul Johnston

unread,
Aug 27, 2018, 5:09:01 PM8/27/18
to bazel-discuss
Meaning that if you put the bazel query //external:* in a genquery, your shell script won't be re-run unless the list of external workspace names changes.  That way the slowness of somepath will be more tolerable as it will be cached.

markus....@ecosia.org

unread,
Aug 28, 2018, 8:01:51 AM8/28/18
to bazel-discuss
You can also see if the query speeds up by using sky-query, i.e. `bazel query --keep_going --universe_scope=//... --order_output=no allrdeps(set(@repo//:all-targets @repo//...:all-targets))` But not sure if that would catch dependencies in .bzl files

Farid Zakaria

unread,
May 31, 2023, 6:02:08 PM5/31/23
to bazel-discuss
genquery isn't allowed * or all in the query itself.
Reply all
Reply to author
Forward
0 new messages