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

Incorrect error from cquery when configuration flag has the default value #15797

Closed
konste opened this issue Jul 3, 2022 · 12 comments
Closed
Labels
bad error messaging Issues where users get stuck because they don't understand what they did wrong P3 We're not considering working on this, but happy to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-Configurability platforms, toolchains, cquery, select(), config transitions type: bug

Comments

@konste
Copy link

konste commented Jul 3, 2022

Description of the bug:

cquery produces incorrect error transition inputs [@//:flavor] do not correspond to valid settings when the flag is not set on the command line or set to the default value.

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

Minimal repro provided here: https://github.com/Bazel-snippets/cquery_transition_error

The following command demonstrates the incorrect error:
bazel cquery somepath(transistor,dummy) --transitions=lite --//:flavor=opt

Error: transition inputs [@//:flavor] do not correspond to valid settings

Omiting of the flag flavoror setting it to the default value opt causes the error. Setting it to dbg avoids the error.

Using --transitions=lite and somepath query function both required to reproduce the problem.

Which operating system are you running Bazel on?

Mac, Linux, Windows

What is the output of bazel info release?

5.2

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

@sgowroji
Copy link
Member

sgowroji commented Jul 4, 2022

Hello @konste, Above shared repo is throwing " syntax error near unexpected token `(' " while reproducing with given demonstrated steps. Could you please verify and share us the complete steps to reproduce the above issue. Thanks!

@konste
Copy link
Author

konste commented Jul 4, 2022

This is weird! I cloned my repository, run bazel cquery somepath(transistor,dummy) --transitions=lite --//:flavor=opt and it reproduced the error just fine! Definitely no syntax errors.
command.log

@sgowroji what is the full error you are seeing? I wonder what line it complains about.

@sgowroji
Copy link
Member

sgowroji commented Jul 5, 2022

This are the logs :


(base) sgowroji-macbookpro:cquery_transition_error sgowroji$ bazel cquery somepath(transistor,dummy) --transitions=lite --//:flavor=dbg
-bash: syntax error near unexpected token `('

Mac OS,
Bazel version :5.2

@fmeum
Copy link
Collaborator

fmeum commented Jul 5, 2022

@sgowroji This is also missing from the original report, but you have to enclose the bazel query query in single quotes or the shell will choke on the ( in the query.

This should work:

bazel cquery 'somepath(transistor,dummy)' --transitions=lite --//:flavor=dbg

@sgowroji sgowroji added type: support / not a bug (process) team-Configurability platforms, toolchains, cquery, select(), config transitions untriaged bad error messaging Issues where users get stuck because they don't understand what they did wrong and removed more data needed labels Jul 5, 2022
@sgowroji
Copy link
Member

sgowroji commented Jul 5, 2022

Thanks @fmeum, Able to reproduce it. @konste Sorry for the confusion.

@gregestren
Copy link
Contributor

Confirmed, thanks.

Triage comment: as you observed, this requires --transitions=lite. I believe what's happening is that the --transitions has to "rerun" transitions in a limited form to produce its output. It's likely re-staging the transition without preemptively loading the build setting defaults, as the actual transition would do.

In other words, Bazel has to know about a build setting to reason about that build setting. When you build with --//:my_setting=foo you're explicitly telling Bazel your build cares about that build setting, so Bazel loads it up, which includes reading its default. When you omit that flag, Bazel has no way of knowing that setting exists until it finds the transition's requirements. In builds that's where the setting is loaded and its default is determined. I suspect cquery's --transitions=lite fails to do that loading.

@gregestren gregestren added P3 We're not considering working on this, but happy to review a PR. (No assignee) and removed untriaged labels Jul 19, 2022
@gregestren
Copy link
Contributor

Indeed, check out:

// TODO(bazel-team): support transitions on Starlark-defined build flags. These require
// Skyframe loading to get flag default values. See ConfigurationResolver.applyTransition
// for an example of the required logic.
)

@konste
Copy link
Author

konste commented Jul 19, 2022

That explanation makes sense to me, but it is still a bug with cquery, right?

@gregestren
Copy link
Contributor

Yes.

@gregestren
Copy link
Contributor

Oh sorry, I didn't see the "not a bug" tag.

@github-actions
Copy link

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team (@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.

@github-actions github-actions bot added the stale Issues or PRs that are stale (no activity for 30 days) label Sep 23, 2023
Copy link

This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please reach out to the triage team (@bazelbuild/triage). Thanks!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 22, 2023
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 P3 We're not considering working on this, but happy to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-Configurability platforms, toolchains, cquery, select(), config transitions type: bug
Projects
None yet
Development

No branches or pull requests

4 participants