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

[buildifier] Autofix for rules not being global breaks your build #785

Closed
limdor opened this issue Feb 10, 2020 · 2 comments
Closed

[buildifier] Autofix for rules not being global breaks your build #785

limdor opened this issue Feb 10, 2020 · 2 comments

Comments

@limdor
Copy link
Contributor

limdor commented Feb 10, 2020

In case of python rules, buildifier warns you with the following message:
Function "py_binary" is not global anymore and needs to be loaded from "@rules_python//python:defs.bzl".
You can also automatically fix it and will add the following line at the top of your BUILD file.
load("@rules_python//python:defs.bzl", "py_binary")
The problem is that before the fix the build is working but after the fix is not working anymore.
Probably is because the rules need to be imported in the WORKSPACE file
https://github.com/bazelbuild/rules_python/releases
It would be nice if the fix would also add the required parts in the WORKSPACE file but I can understand that then is modifying a file that is not the active one. The other option would be to add a more explanatory message that guides the user on how to solve it.
Maybe the main question for the buildifier developers is if it is accepted that an automatic fix makes your build stop working.

@peloton-mqiu
Copy link

thanks @limdor for linking the release.

After adding the following line to my WORKSPACE, my bazel is able to find where to load rules_python:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_python",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.0.3/rules_python-0.0.3.tar.gz",
    sha256 = "e46612e9bb0dae8745de6a0643be69e8665a03f63163ac6610c210e80d14c3e4",
)
load("@rules_python//python:repositories.bzl", "py_repositories")
py_repositories()

@limdor
Copy link
Contributor Author

limdor commented Nov 28, 2021

Because buildifier does no longer warns about this anymore I do not think that it is worth to keep the issue opened. I will close it to contribute a bit on issue cleanup.
For more information see:
bazelbuild/bazel#9006
#923
#952

@limdor limdor closed this as completed Nov 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants