bazelbuild / bazel-watcher

Tools for building Bazel targets when source files change.
Apache License 2.0
440 stars 116 forks source link

ibazel ought to use CQuery instead of regular query #594

Closed jakeleventhal closed 1 year ago

jakeleventhal commented 1 year ago

Describe the bug Running bazel build <target> then bazel query <target> invalidates the cache sometimes because bazel query doesn't consider select statements.

Reproduction instructions Any repo with a target with select statements. Run the above commands and see the cache is invalidated.

Expected behavior The cache should not be invalidated. This leads to really long boot up times.

Version (please complete the following information):

csmulhern commented 1 year ago

I believe ac2ce9f might have broken something with ibazel. I'm seeing this error when running ibazel:

ERROR: Error doing post analysis query: Evaluation failed: buildfiles() doesn't make sense for the configured target graph
INFO: Elapsed time: 0.102s, Critical Path: 0.00s
INFO: 0 processes.
FAILED: Build did NOT complete successfully
iBazel [9:14AM]: Bazel cquery failed: exit status 1
iBazel [9:14AM]: Error querying for source files: exit status 1

I believe this means that ibazel will not reload if there are changes to BUILD / bzl files that affect the watched target. I believe the issue is that buildfiles only works with query, not cquery.

The fix is to have this query still use query, rather than cquery:

https://github.com/bazelbuild/bazel-watcher/blob/8af081faf7e9995feec9f7977cf29d6c87966c19/internal/ibazel/ibazel.go#L309

loeffel-io commented 1 year ago

same here!

purkhusid commented 1 year ago

Same error here. Any chance we could rollback the change @achew22 ?

achew22 commented 1 year ago

Yeah, let's roll it back

achew22 commented 1 year ago

Looks like there may be more complexity here than initially thought. Rolling back to restore functionality. Thanks for the reporting everyone!

jakeleventhal commented 1 year ago

This issue should be reopened. The cache invalidation issue still exists

github-actions[bot] commented 1 year ago

Stale issue message