Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uninformative error message with invalid select key #17689

Closed
Wyverald opened this issue Mar 8, 2023 · 4 comments
Closed

Uninformative error message with invalid select key #17689

Wyverald opened this issue Mar 8, 2023 · 4 comments
Labels
bad error messaging Issues where users get stuck because they don't understand what they did wrong P2 We'll consider working on this in future. (Assignee optional) team-Configurability platforms, toolchains, cquery, select(), config transitions type: bug

Comments

@Wyverald
Copy link
Member

Wyverald commented Mar 8, 2023

Description of the bug:

The error message Bazel displays when a target uses an invalid select key is very uninformative. In particular, it doesn't tell you where the offending usage occurs.

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

touch WORKSPACE
echo 'java_library(name="a", deps=["//b"])' > BUILD
mkdir b
echo 'java_library(name="b", deps=select({"//c": []}))' > b/BUILD

When you run bazel build :a, you get the following error message (and nothing else):

ERROR: Analysis of target '//:a' failed; build aborted: no such package 'c': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package.
 - /Users/wyv/test/another-test/c

It doesn't tell you that //c is being referred to from the file b/BUILD. If :a has lots of deps, it's nigh impossible to figure out what's wrong.

Which operating system are you running Bazel on?

macOS

What is the output of bazel info release?

release 6.1.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 ?

No response

Have you found anything relevant by searching the web?

No response

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

No response

@Wyverald Wyverald added type: bug team-Configurability platforms, toolchains, cquery, select(), config transitions untriaged labels Mar 8, 2023
@Wyverald
Copy link
Member Author

Wyverald commented Mar 8, 2023

cc @katre

@Wyverald
Copy link
Member Author

Wyverald commented Mar 8, 2023

For the record, to figure out what was wrong initially, I had to build my own Bazel and insert a line in PackageValue#key to crash immediately when the requested package identifier is //c o,o

@gregestren gregestren added the bad error messaging Issues where users get stuck because they don't understand what they did wrong label Mar 13, 2023
@gregestren
Copy link
Contributor

We have a long history of analysis errors not always propagating cleanly. I can't tell offhand if this is specifically about select() or the broader analysis error issue.

Either way, good point. Agreed on the bad messaging.

@gregestren
Copy link
Contributor

Probed a little bit. I wonder if we need to propagate the lookup error from

SkyframeLookupResult packageAndMaybeConfigurationValues =
env.getValuesAndExceptions(packageAndMaybeConfiguration);
if (env.valuesMissing()) {
return null;
?

@gregestren gregestren added P2 We'll consider working on this in future. (Assignee optional) and removed untriaged labels Mar 13, 2023
fweikert pushed a commit to fweikert/bazel that referenced this issue May 25, 2023
If a key in a `select` references a package that does not exist, the error message now includes a reference to the target with the `select`:

```
ERROR: no such package 'hello/c': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package.
 - /tmp/bazel-crash/hello/c
ERROR: /tmp/bazel-crash/hello/b/BUILD:1:13: errors encountered resolving select() keys for //hello/b:b
ERROR: Analysis of target '//hello/a:a' failed; build aborted
```

Previously, it didn't:
```
ERROR: Analysis of target '//hello/a:a' failed; build aborted: no such package 'hello/c': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package.
 - /tmp/bazel-crash/hello/c
```

Fixes bazelbuild#17689

Closes bazelbuild#18454.

PiperOrigin-RevId: 533635167
Change-Id: I714b1c1c539d9dfb76dea9b6f1899bb98ae558dd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bad error messaging Issues where users get stuck because they don't understand what they did wrong P2 We'll consider working on this in future. (Assignee optional) team-Configurability platforms, toolchains, cquery, select(), config transitions type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants