--features=feature_a,feature_b is not the same as --features=feature_a --features_b
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 75
Description
### Description of the bug:
In Bazel, you have to types of command line parameters, some that you can pass comma separated values like `--test_tag_filters` and some that you can pass multiple values specifying the parameter multiple times like `--features`.
The problem we had here, was that we tried to pass `--features` like if would be a comma separated value. (i.e. `--features=featurea_a,feature_b`. Intuitively we would have expected both `feature_a` and `feature_b` to be enabled, but that was not the case. We assume that Bazel takes `feature_a,feature_b` as a single string, and because if a feature is not implemented by a toolchain is ignored, that is fine.
Until here it is unfortunate but I can understand the behavior. However, why would it make sense this behavior? The only time that makes sense is if it would be possible to define a feature with the name `feature_a,feature_b`. However, if you try to do that, you will get a Bazel error as follows:
`Error in create_cc_toolchain_config_info: in FeatureInfo instantiated at /home/xb/.cache/bazel/_bazel_xb/d322d9e7202fdf5f81e4f8ec750a774d/external/bazel_tools/tools/cpp/cc_toolchain_config_lib.bzl:395:23: A feature's name must consist solely of lowercase ASCII letters, digits, '.', '_', '+', and '-', got 'standard_cpp_14,standard_cpp_17'`
Now we could discuss if this is a bug or a feature request. The documentation is clear that it expect a string and not a comma separated list. However we just strive for good user experience.
What we would expect is that Bazel gives an error if someone is passing a feature name that contains a comma `,`.
One last thing, it is not so strange that the user expects that comma separated is allowed, in the end it is called `--features` (plural) and not `--feature` (singular).
### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Provide to enable multiple features this way and use `--subcommand=pretty_print` to see if they are applied.
### Which operating system are you running Bazel on?
Linux
### What is the output of `bazel info release`?
6.2.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_
### Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.
_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_
Contributor guide
Research direction
Reproduce the behavior with --features=feature_a,feature_b and inspect the result using --subcommand=pretty_print. Trace how repeated --features values are parsed and validated, then confirm that a comma-containing feature name produces a clear error without changing valid repeated-value behavior.
Written by the indexing model from the issue text.
Assessment
- Domain
- build-system, cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100