Search code examples
bazelbazel-query

Running bazel query without downloading external dependencies


Given a rather big repository built with bazel and tons of third party dependencies in multiple languages (including heavy docker containers), I have the following problem:

running Bazel queries triggers the downloading of many of these dependencies, resulting in slow query performance. Hence, the question:

Is there a way to run bazel query without having to download the dependencies?

Typical query: bazel query 'kind("source file", deps(//...) except deps(//3rdparty/...))

I'm aware of the caching options, which I mostly use, but depending on the languages, things can still be slow.


Solution

  • After asking on Bazel's Slack channel, the response (from Sahin Yort) is not encouraging:

    I don’t believe that’s possible due to nature of workspace files. loads from a workspace leads to fetch of the given workspace because has to expand the workspaces in order to know their targets. at that point, it is up to the repository rule to fetch whatever it needs to fetch eagerly or lazily. workspace rules usually expand BUILD files using various patterns. eg running a executable or using expand_template. i have little faith in that it is possible to get what you want.

    I'll be looking into other ways to speed things up: a likely culprit for the slowness is probably the action/analysis cache being invalidated due to some flags changing.