bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
23.24k stars 4.08k forks source link

Error doing post analysis query: Evaluation failed: Unable to load package #17526

Open cameron-martin opened 1 year ago

cameron-martin commented 1 year ago

Description of the bug:

Under certain conditions, when I run bazel cquery or bazel aquery, it errors with the following message:

ERROR: Error doing post analysis query: Evaluation failed: Unable to load package '[/home/cameronm/.cache/bazel/_bazel_cameronm/0465fca5c3fb7ad56482d91d46c984ea/external/bazel_skylib]/[]' because package is not in scope. Check that all target patterns in query expression are within the --universe_scope of this query.

I'm not 100% sure what those conditions are, but there is a reproducer below. I know that the presence and modification of the .bazelignore file affects this, as does some third-party pip WORKSPACE macro.

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

https://github.com/cameron-martin/bazel_cquery_bug

See the README for more info

Which operating system are you running Bazel on?

Ubuntu 18.04

What is the output of bazel info release?

release 6.0.0

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

git@github.com:cameron-martin/bazel_cquery_bug.git
a2a8e9ed0dd0f795cb2079e358d174b8198a4ee1
a2a8e9ed0dd0f795cb2079e358d174b8198a4ee1

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

There is a slack thread about it here: https://bazelbuild.slack.com/archives/CA31HN1T3/p1676643124133759

matt-sm commented 6 months ago

+1 I ran into this same issue when trying to run an aquery on an external.

This is a somewhat of a blocker for the project I'm working on, as we rely on aquery output to produce a unqiue identifier for bazel-built packages.

And much the same as the minimal example, when I delete .bazelignore aquery works.

moroten commented 1 month ago

Does Bazel 7.4.0 and #22142 solve this for you?