-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Consider removing bind() #1952
Comments
|
I think all bind uses-cases can be replaced with alias but it does not strike me as high priority. bind() has that weird thing that it creates a //external package that does not really exists, so only for that I would say +1 |
It might be worth putting a quick change in the documentation saying that bind() is or will likely be deprecated and that alias should be used instead, or simply vanilla external repository names. That should hopefully lessen any refactoring we'll have to do in the future, if it is removed. |
Considering that I'm not really sure we want to do that, I'd rather not deprecate |
Then would Bazel at the very least be open to a documentation change On Oct 18, 2016 1:45 AM, "lberki" [email protected] wrote:
|
It looks like this could be related to a problem I'm trying to solve. When I try to build my Tensorflow Serving client I'm getting this:
Any idea how I can fix this? I'm on Ubuntu 14.04 |
@robertcrowe Did you modify the workspace.bzl file? Can you start a separate issue for this and CC me? |
+1 to removing bind, updating the docs in the meantime seems like a good idea. |
I reviewed the code to rules_web yesterday, which was recently introduced and makes extensive use of bind(). It uses bind() to allow the user to override executable attributes on its Skylark rules without having to repeat them every time the rule is used. I had a discussion with @DrMarcII about this. We both came to the conclusion that it would be better if those attributes were public and the user defined macro wrappers that customize the attribute. I'm glad we're building consensus around removing bind(). Right now it's the first rule listed in the documentation, but it's actually the last rule we'd want to use. The same is true for git_repository(), which is also listed first, but has the biggest negative impact on performance for the project in question, and all dependent projects. Many users make use of these rules without considering the alternatives, like grabbing the snapshot tarball from GitHub. Whatever we can do to help the user make the correct choices, especially if we make the wrong choices impossible, is going to go a long way to fostering a healthy and lightning fast build ecosystem spanning many GitHub projects that all reference each other. |
The order of the rules are a bit random, I don't think they matter. Anyway, IMO:
On Wed, Oct 19, 2016 at 8:36 PM Justine Tunney [email protected]
|
On Thu, Oct 20, 2016 at 12:54 AM, Damien Martin-Guillerez <
+1
Sure, but please also mirror it into the official docs somehow; people |
@damienmg why are maven_jar and git_repository being deprecated? |
They are being replaced with skylark implementation from new_* is indeed not the replacement version On Tue, Nov 1, 2016 at 11:02 AM Ittai Zeidman [email protected]
|
I don't see it mentioned is this thread, so I thought I should mention, the AndroidSdkRepositoryFunction makes use of bind so that android_binary can depend on the android_sdk generated by AndroidSdkRepositoryFunction without needing to know the name of the android_sdk_repository rule. |
Which I think is a mistake, as I think I'm mentioned before. The android_sdk rule still depends on the external name, which is no better that depending on the repository name. |
Sorry, what do you mean by "the android_sdk rule still depends on the external name"? Do you mean that the name of the android_sdk rule is the name of the android_sdk_repository rule? Or that the "bound" name refers to the external name? |
Whoops, I mistyped, I meant the android_binary rule. The android_binary rule depends on something like |
Hmmm, why would that be better? that would require that every developer name their I agree with you that |
You are already requiring every developer to declare an android_sdk_repository and bind it to a certain name: this eliminates one of those steps. Also, you could make it a macro and set the name in the macro, e.g.,
|
I don't think we are. The developer does not have to use a bind() in their WORKSPACE. We create the bind under the hood: bazel/src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidSdkRepositoryRule.java Line 57 in 0f0f383
E.g., the following works:
I guess if we remove the user-visible I'm going to open another issue to address your comment about the macro, because I like that idea a lot. 😄 |
I'm -1 on removing or deprecating bind. Suppose you have two external bazel repository dependencies, A, B. Each of which needs dependency foo. One of them expects it at I think the right way to go here is that I wish the bazel core team had someone whose role was explicitly to advocate for the many external repo use case (hopefully many of them bazel). That is the use case of the vast numbers of people using most existing tools (and migration to monorepo as a precondition to use bazel is not so workable, especially in open source: what would that even mean?_ |
* explicitly load git_repository rule * load googletest as a git_repository * stop using bind (see bazelbuild/bazel#1952)
* explicitly load git_repository rule * load googletest as a git_repository * stop using bind (see bazelbuild/bazel#1952)
I am looking at the exact item mentioned by @jart at the top
Reading through this thread, it's still not evident to me how I solve this problem. Can someone provide guidance on how I could have a |
@damienpontifex Check out repository remapping:
|
…_bzl. ...by load()-ing java_library and other rules wherever we use them. Compare to CL 297412705 for Flogger. This CL includes updating to a new version of bazel_common to avoid --incompatible_load_java_rules_from_bzl errors in bazel_common. See google/bazel-common#104. Note that this CL also changes the way we get zlib() (a dependency of protobuf) from bind() to http_archive(). http_archive() seems to be the more recommended pattern: - https://docs.bazel.build/versions/master/external.html#repository-rules - bazelbuild/bazel#1952 But my immediate motivation was that bind() wasn't working with the new version of protobuf. (The new version of protobuf is necessary to avoid --incompatible_load_java_rules_from_bzl errors inside protobuf. It comes with the new version of bazel_common.) ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=297608393
…_bzl. ...by load()-ing java_library and other rules wherever we use them. Compare to CL 297412705 for Flogger. This CL includes updating to a new version of bazel_common to avoid --incompatible_load_java_rules_from_bzl errors in bazel_common. See google/bazel-common#104. Note that this CL also changes the way we get zlib() (a dependency of protobuf) from bind() to http_archive(). http_archive() seems to be the more recommended pattern: - https://docs.bazel.build/versions/master/external.html#repository-rules - bazelbuild/bazel#1952 But my immediate motivation was that bind() wasn't working with the new version of protobuf. (The new version of protobuf is necessary to avoid --incompatible_load_java_rules_from_bzl errors inside protobuf. It comes with the new version of bazel_common.) ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=297608393
We have no plans to deprecate bind. |
In that case, the documentation should be updated. It should probably explain some of the potential misuses and better alternatives, along with valid use cases. |
Hello, As of today (2021-02-07) the master build encyclopedia still suggests that usage of bind() is not recommended, with a link to this bug. If it is indeed the case, as in #1952 (comment), that there are no plans to deprecate bind(), and—as commented upon above by several—it exists to solve problems that cannot be solved in an alternative manner, then this warning should be removed. While I see much conversation above about it in regards specifically to Maven and Java, this is not my use case, and reading the documentation, and then following the link to this bug, gives me no more insight as to whether or not bind() is suitable for my use case. As can be seen above, many repositories link to this bug as an explanation as to why bind() should not be used, such as liucijus/rules_scala#1 which mentions removing use of the "problematic bind()". The warning on the documentation, and this bug, has created a feedback loop where projects will simply be asked to remove the use of bind(), by pointing to the warning in the documentation (e.g. grpc/grpc#13902), even though, as #1952 (comment) states, there are no plans to deprecate it, and the warning was added in response to this bug. If it's not recommended, there should be a clear and specific justification in the documentation directly, or a specific deprecation plan. If the usage of bind() is not problematic, this should also be made clear. |
@Wyverald how does |
Overall, I don't think |
The Bzlmod documentation states
If it is really deprecated then the documentation should state that and there should be a deprecation/removal timeline communicated. |
The page you linked to says "Warning: use of bind() is not recommended." . I thought that qualified as a deprecation warning, doesn't it? |
What is the use case for bind()? I can't think of one. Even in situations where there are multiple ABI-compatible implementations of a library (e.g. OpenSSL, BoringSSL, etc.) this problem could still be solved by using vanilla externals.
Most Bazel projects don't seem to use bind(). The ones that do, it seems to have caused problems.
For example, the protobuf repository, rather than defining a
protobuf_repositories()
function, simply uses//external:foo
for every single target upon which it depends, thereby punting the burden defining bind() rules not only for every single external, but every target within those externals.As a result, the TensorFlow workspace.bzl file has developed a cargo cult pattern where superfluous bindings will be added, because I don't think people really understand what bind() does.
What is especially suboptimal is that the bind() namespace overlaps with the external repository namespace. We can't name externals like "six" to be "@six" because the protobuf BUILD file asked us for
//external:six
. So we don't have a choice. We have to name it@six_archive
, which hurts readability. It would have been more optimal if the protobuf BUILD file should have just asked for@six//:six
.It would be nice if we could retire bind() and help projects like protobuf migrate to the foo_repositories() model that official Bazel projects use. We could recommend as a best practice the technique that is employed by the Closure Rules repositories.bzl file.
This gives dependent Bazel projects the power to schlep in transitive Closure Rules dependencies using either a whitelist or blacklist model. For example, one project that uses Closure Rules has the following in its WORKSPACE file:
Because it directly depends on those transitive dependencies and wants to specify them on its own.
I think this is a much more desirable and flexible pattern than bind().
The text was updated successfully, but these errors were encountered: