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

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

Open
jonathan-enf opened this issue Dec 10, 2024 · 2 comments
Labels
team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. team-Rules-CPP Issues for C++ rules type: bug under investigation

Comments

@jonathan-enf
Copy link

jonathan-enf commented Dec 10, 2024

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

@github-actions github-actions bot added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. team-Rules-CPP Issues for C++ rules labels Dec 10, 2024
@jonathan-enf
Copy link
Author

I could spend time building a simple repro case -- but I suspect the solution is not to fix this behavior, but to detect and error out under these circumstances.

@fmeum
Copy link
Collaborator

fmeum commented Dec 13, 2024

Could you test with Bazel 8 and --noenable_workspace? #23791 added logic to show an error in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. team-Rules-CPP Issues for C++ rules type: bug under investigation
Projects
None yet
Development

No branches or pull requests

6 participants