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

External repository referring unexported files #15185

Closed
linzhp opened this issue Apr 5, 2022 · 5 comments
Closed

External repository referring unexported files #15185

linzhp opened this issue Apr 5, 2022 · 5 comments
Assignees
Labels
not stale Issues or PRs that are inactive but not considered stale P2 We'll consider working on this in future. (Assignee optional) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug

Comments

@linzhp
Copy link
Contributor

linzhp commented Apr 5, 2022

Description of the problem / feature request:

When an external repository refers to an unexported files, builds can still succeed, only queries with deps would fail. This is inconsistent.

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

  • Create a workspace like this:
-- WORKSPACE --
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "com_google_protobuf",
    sha256 = "d0f5f605d0d656007ce6c8b5a82df3037e1d8fe8b121ed42e536f569dec16113",
    strip_prefix = "protobuf-3.14.0",
    urls = [
        "https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/v3.14.0.tar.gz",
        "https://github.com/protocolbuffers/protobuf/archive/v3.14.0.tar.gz",
    ],
)

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()
-- BUILD.bazel --
  • Run bazel build @zlib//:all, it would succeed
  • Run bazel query 'deps(//external:zlib)', it would fail with:
ERROR: /private/tmp/protobuf/WORKSPACE:15:14: no such target '@com_google_protobuf//:third_party/zlib.BUILD': Label '@com_google_protobuf//:third_party/zlib.BUILD' crosses boundary of subpackage '@com_google_protobuf//third_party' and referenced by '//external:zlib'
ERROR: /private/tmp/protobuf/WORKSPACE:15:14: no such target '@com_google_protobuf//:third_party/zlib.BUILD': target 'third_party/zlib.BUILD' not declared in package ''; however, a source file of this name exists.  (Perhaps add 'exports_files(["third_party/zlib.BUILD"])' to /BUILD?) defined by /private/var/tmp/_bazel_zplin/67edb565efa10fe0537e4ddaba8aef74/external/com_google_protobuf/BUILD and referenced by '//external:zlib'
ERROR: Evaluation of query "deps(//external:zlib)" failed: errors were encountered while computing transitive closure

What operating system are you running Bazel on?

macOS

What's the output of bazel info release?

release 5.1.0

Any other information, logs, or outputs that you want to share?

This bug has existed for a long time. #8175 is a symptom of it. #15134 fixed the symptom, but it doesn't prevent it from coming back.

@meteorcloudy
Copy link
Member

I think the reason is that protobuf should use @com_google_protobuf//third_party:zlib.BUILD at here

But somehow we didn't check if the label is valid when using in the WORKSPACE file.

@meteorcloudy meteorcloudy added type: bug P2 We'll consider working on this in future. (Assignee optional) and removed untriaged labels Apr 6, 2022
@meteorcloudy
Copy link
Member

I think the underlying problem is that when a label is used in the WORKSPACE file to reference a file, we are actually not loading the target (that's when we check if the label is crossing boundary). But we do try to load targets from the label when running bazel query.

@github-actions
Copy link

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team (@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.

@github-actions github-actions bot added the stale Issues or PRs that are stale (no activity for 30 days) label Jun 14, 2023
@linzhp
Copy link
Contributor Author

linzhp commented Jun 14, 2023

@bazelbuild/triage Can you keep this open?

@Pavank1992 Pavank1992 added not stale Issues or PRs that are inactive but not considered stale and removed stale Issues or PRs that are stale (no activity for 30 days) labels Jun 14, 2023
@Wyverald
Copy link
Member

bazel query deps(//external:foo) was never going to work as targets under //external are pseudo-targets and don't actually behave like other, actual build targets. Regardless, we won't be fixing this as the entire //external package will be going away with WORKSAPCE deprecation.

@Wyverald Wyverald closed this as not planned Won't fix, can't repro, duplicate, stale Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not stale Issues or PRs that are inactive but not considered stale P2 We'll consider working on this in future. (Assignee optional) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug
Projects
None yet
Development

No branches or pull requests

5 participants