Skip to content

--override_repository allows overriding non-existant repos, but then misbehaves #24617

@jonathan-enf

Description

@jonathan-enf

Description of the bug:

I've learned something interesting. If my WORKSPACE file declares an external repository named "foo", then this works:

bazel build --override_repository=foo=/tmp/myfoo @foo//:some_cc_library_target

But, if I instead run with a repo name that doesn't exist in my WORKSPACE file:

bazel build --override_repository=bar=/tmp/myfoo @bar//:some_cc_library_target

then the same target will fail compilation (because, oddly, a #include statement will report a file not found error. Digging deeper, the generated gcc commandline is missing -iquote . -iquote bazel-out/k8-fastbuild/bin)

I'm not saying that bazel should support insertion of arbitrary new repository contexts via --override_repository, but if this isn't going to be supported it would be nice if bazel explicitly errored out under those circumstances, rather than seeming to work but reporting a compiler error.

Which category does this issue belong to?

C++ Rules, External Dependency

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

As described above: create an external repo containing a single cc_library rule. That cc_library rule must contain a #include on a header file that is part of the rule.

Which operating system are you running Bazel on?

linux

What is the output of bazel info release?

release 6.5.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 HEAD ?

No response

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3We're not considering working on this, but happy to review a PR. (No assignee)team-ExternalDepsExternal dependency handling, remote repositiories, WORKSPACE file.team-Rules-CPPIssues for C++ rulestype: bugunder investigation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions