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

Flag aliases are not expanded before error in query like commands #25116

Open
luispadron opened this issue Jan 28, 2025 · 5 comments · May be fixed by #25125
Open

Flag aliases are not expanded before error in query like commands #25116

luispadron opened this issue Jan 28, 2025 · 5 comments · May be fixed by #25125
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) query bugs Bugs related to "bazel (c)query" team-Configurability platforms, toolchains, cquery, select(), config transitions type: bug

Comments

@luispadron
Copy link
Contributor

luispadron commented Jan 28, 2025

Description of the bug:

Flag aliases do not seem to work when going through the query command.

Which category does this issue belong to?

No response

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

  1. Use a flag alias
  2. Use the alias in the build
  3. Run query with the alias

Example:

bazel build //... --flag_alias=swift_copt=@build_bazel_rules_swift//swift:copt --swift_copt=-swift-version --swift_copt=6
...
PASSES
bazel query //... --flag_alias=swift_copt=@build_bazel_rules_swift//swift:copt --swift_copt=-swift-version --swift_copt=6
...
ERROR: --swift_copt=-swift-version :: Unrecognized option: --swift_copt=-swift-version

Which operating system are you running Bazel on?

macOS 15.3

What is the output of bazel info release?

release 7.4.1

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 HEAD ?


If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

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

@fmeum
Copy link
Collaborator

fmeum commented Jan 28, 2025

Do they work with cquery? query runs on the unconfigured graph and thus doesn't take any Starlark flag values into account.

@luispadron
Copy link
Contributor Author

Do they work with cquery? query runs on the unconfigured graph and thus doesn't take any Starlark flag values into account.

I can check tomorrow but pretty sure they would.

This feels like the older common like issues where build/query commands would support different flags. It's fine if query doesn't actually use the flag but I was hoping to use the alias in my rc like I currently do with common and the starlark flag

@sgowroji sgowroji added team-Configurability platforms, toolchains, cquery, select(), config transitions query bugs Bugs related to "bazel (c)query" labels Jan 29, 2025
@fmeum
Copy link
Collaborator

fmeum commented Jan 29, 2025

I sent #25125 to allow

$ cat .bazelrc
common --flag_alias=my_flag=//:my_flag
common --my_flag=value
$ bazel query //...

In the issue description, you explicitly specify --flag_alias and the alias on the query command line, which is a different situation in which an error is probably reasonable (as for any non-Starlark flag unsupported by query). Does that make sense for you?

@luispadron
Copy link
Contributor Author

Ah yeah my bad should've showcased the actual .bazelrc usage example i was hitting (which your PR fixes, thank you!). I do think the error message here is slightly confusing, or that the alias should still work but then fail later if the flag doesn't work with query.

@gregestren gregestren added P3 We're not considering working on this, but happy to review a PR. (No assignee) and removed untriaged labels Feb 3, 2025
@luispadron luispadron changed the title Flag aliases do not work in query like commands Flag aliases are not expanded before error in query like commands Feb 4, 2025
@luispadron
Copy link
Contributor Author

Updated the title here if we want to address it. #25125 fixes the main issue for me and this issue can be used to track the error message stating that the expanded flag is not supported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) query bugs Bugs related to "bazel (c)query" team-Configurability platforms, toolchains, cquery, select(), config transitions type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants