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

bazel query rdeps fails in //external because //:dummy target doesn't exist #8175

Closed
jschaf opened this issue Apr 28, 2019 · 3 comments
Closed
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Android Issues for Android team type: bug

Comments

@jschaf
Copy link

jschaf commented Apr 28, 2019

Description of the problem / feature request:

Using rdeps against the //external package fails because Bazel tries to resolve the android_sdk_for_testing bind rule to //:dummy using the local repository instead of Bazel's root BUILD.

# src/main/java/com/google/devtools/build/lib/bazel/rules/android/android.WORKSPACE
bind(
    name = "android_sdk_for_testing",
    actual = "//:dummy",
)

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

# WORKSPACE
workspace(name = "bazel_dummy_target")
bazel query 'rdeps(//external:*, //external:bazel_tools, 3)'
ERROR: /DEFAULT.WORKSPACE:25:1: no such target '//:dummy': target 'dummy' 
  not declared in package '' defined by <BAZEL>/BUILD.bazel 
  and referenced by '//external:android_sdk_for_testing'

ERROR: /DEFAULT.WORKSPACE:25:1: no such target '//:dummy': target 'dummy' 
  not declared in package '' defined by <BAZEL>/BUILD.bazel 
  and referenced by '//external:android_sdk_for_testing'

What operating system are you running Bazel on?

MacOS

What's the output of bazel info release?

release 0.24.1

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

A workaround is to add the dummy target in my local repo. It seems like Bazel should use it's own dummy target.

filegroup(
    name = "dummy",
    visibility = ["//visibility:public"],
)
@jin jin added team-Android Issues for Android team untriaged labels Apr 29, 2019
@ahumesky ahumesky added P2 We'll consider working on this in future. (Assignee optional) and removed untriaged labels Apr 30, 2019
linzhp added a commit to linzhp/bazel that referenced this issue Mar 29, 2022
@comius
Copy link
Contributor

comius commented Mar 29, 2022

I'm surprised that depending on jdk.BUILD only throws an error on query, but not already when the target is defined. It looks like there is another bug, that allows repo rules to depend on un-exported files from other packages.

bazel-io pushed a commit that referenced this issue Mar 31, 2022
We need to query `kind('source file', deps(//external:*))` for sparse checkout, but were block by two issues:

* `//external:remotejdk11_linux` depends on `tools/jdk/jdk.BUILD`, but it was not exported. Although this is not a problem for build, queries like `kind('source file', deps(//external:remotejdk11_linux))` would fail.
* `//external:android_sdk_for_testing` is an alias for `//:dummy`, which is not available in other repositories. This also caused #8175.

This pull request fixed both, including #8175.

Closes #15134.

PiperOrigin-RevId: 438605051
@linzhp
Copy link
Contributor

linzhp commented Mar 31, 2022

@jschaf @ahumesky I believe this can be closed.

@comius I agree. Many repos exploited this bug. Here is another example, in which //:third_party/zlib.BUILD is not exported:

https://github.com/protocolbuffers/protobuf/blob/eb8976a56d3f596ada8562dcff27724fb3f3625c/protobuf_deps.bzl#L31-L37

@linzhp
Copy link
Contributor

linzhp commented Apr 5, 2022

@comius created #15185 to follow up.

ckolli5 pushed a commit that referenced this issue May 9, 2022
We need to query `kind('source file', deps(//external:*))` for sparse checkout, but were block by two issues:

* `//external:remotejdk11_linux` depends on `tools/jdk/jdk.BUILD`, but it was not exported. Although this is not a problem for build, queries like `kind('source file', deps(//external:remotejdk11_linux))` would fail.
* `//external:android_sdk_for_testing` is an alias for `//:dummy`, which is not available in other repositories. This also caused #8175.

This pull request fixed both, including #8175.

Closes #15134.

PiperOrigin-RevId: 438605051
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Android Issues for Android team type: bug
Projects
None yet
Development

No branches or pull requests

5 participants