Skip to content

bazelrc: Allow "common" lines to always accept any legal Bazel options #3054

@mmorearty

Description

@mmorearty

Description of the problem / feature request / question:

Currently, if a bazelrc file contains a common line, then all of the specified options are passed to every bazel command that is run. I propose that the common line always allow all legal options that can apply to any command, but silently ignore the ones that don't apply to the current command.

The current behavior can easily lead to unnecessary error messages, and greatly hampers the usefulness of the common feature.

For one thing, there are very few Bazel options that are actually common across every command.

Also, although bazelrc supports inheritance (e.g. test and run will automatically inherit from any build lines), that inheritance isn't always enough. For example, suppose I want to have a custom --package_path for every Bazel command that supports that flag. It's not sufficient to write

build --package_path ...

because that will apply to build, test, and run, but not to fetch, info, and query, which do not inherit from build but do support the --package_path option.

I could write

build --package_path ...
fetch --package_path ...
info --package_path ...
query --package_path ...

But that is (a) messy, (b) requires me to do a lot of research to carefully figure out which commands support --package_path, and (c) could break in the future if I upgrade to a newer version of Bazel that supports --package_path for additional commands.

What I really want is to write

common --package_path ...

but I can't, because that breaks any command that doesn't support that flag, such as bazel help.

I think probably the best way to address this is what I proposed above: The common line always allows all legal options that can apply to any command, but silently ignores the ones that don't apply to the current command.

So common --package_path ... would never cause an error, but common --invalid_flag would cause an error.

Environment info

  • Operating System:

OS X

  • Bazel version (output of bazel info release):

0.4.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2We'll consider working on this in future. (Assignee optional)team-CoreSkyframe, bazel query, BEP, options parsing, bazelrctype: feature request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions