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

Direct access to the native Python rules is deprecated #19

Closed
aminya opened this issue Jan 25, 2022 · 4 comments
Closed

Direct access to the native Python rules is deprecated #19

aminya opened this issue Jan 25, 2022 · 4 comments

Comments

@aminya
Copy link

aminya commented Jan 25, 2022

When I try to use this tool by running bazel run @hedron_compile_commands//:refresh_all, I get this error:

 >>> Analyzing commands used in @//...
DEBUG: Rule 'hedron_compile_commands' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = "a3ee1e3a778489bc9f831a3ce6c5293c688c2d22f743f8bec97b7037812e6184"
DEBUG: Repository hedron_compile_commands instantiated at:
  /home/aminya/drake/WORKSPACE:28:13: in <toplevel>
Repository rule http_archive defined at:
  /home/aminya/.cache/bazel/_bazel_aminya/e28718b65588b6f1482a6ab238164c48/external/bazel_tools/tools/build_defs/repo/http.bzl:336:31: in <toplevel>
DEBUG: Rule 'hedron_compile_commands' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = "a3ee1e3a778489bc9f831a3ce6c5293c688c2d22f743f8bec97b7037812e6184"
DEBUG: Repository hedron_compile_commands instantiated at:
  /home/aminya/drake/WORKSPACE:28:13: in <toplevel>
Repository rule http_archive defined at:
  /home/aminya/.cache/bazel/_bazel_aminya/e28718b65588b6f1482a6ab238164c48/external/bazel_tools/tools/build_defs/repo/http.bzl:336:31: in <toplevel>
ERROR: /home/aminya/.cache/bazel/_bazel_aminya/e28718b65588b6f1482a6ab238164c48/external/hedron_compile_commands/BUILD:19:10: in py_binary rule @hedron_compile_commands//:extract: Direct access to the native Python rules is deprecated. Please load py_binary from the rules_python repository. See http://github.com/bazelbuild/rules_python and https://github.com/bazelbuild/bazel/issues/9006. You can temporarily bypass this error by setting --incompatible_load_python_rules_from_bzl=false.
ERROR: Analysis of target '@hedron_compile_commands//:extract' failed; build aborted: Analysis of target '@hedron_compile_commands//:extract' failed
ERROR: Build failed. Not running target
 >>> Finished extracting commands for @//...

How can I fix this?

@cpsauer
Copy link
Contributor

cpsauer commented Jan 25, 2022

Hi, @aminya! Thanks for giving this tool a try--and sorry things aren't working for you out of the box. It's great to have you here with us :) Pretty amazing GitHub profile you have.

TL;DR: Things should work if you don't set the (undocumented, default false) --incompatible_load_python_rules_from_bzl!
If it's getting set via --all_incompatible_changes, you almost certainly don't want to set that flag either. (It's discouraged and in the process of being removed, per docs and parallel issue.)

In more detail + why we probably shouldn't make code changes here:
Bazel's error message is trying to give us clues about what's going on--and doing a decent job, I think, though it's a little out of date. It's letting you know that you're seeing the error because of --incompatible_load_python_rules_from_bzl, and links us to an issue that discusses it. In that issue, Bazel folks note that they've reversed course on the decision that motivated the creation of that flag (requiring people to load rules that were formerly bundled automatically), and have closed the issue because they don't intend to flip the flag. My take is that it's probably better to not change the code in this repo to go with a migration that isn't happening--hence the suggestions about the flags. I'll drop them a quick note about maybe removing the flag.

All the best,
Chris

P.S. The warnings are about a different thing, suggesting adding a sha256 = to the http_archive load of this project. I'd recommend that--but I'd recommend even more strongly that you update to the latest commit! It looks like you might be using an older version of this tool.

@cpsauer
Copy link
Contributor

cpsauer commented Jan 25, 2022

I'm going to close this (optimistically), but if that fix isn't working, lmk, and I'll reopen it and jump right back in with you.

@aminya
Copy link
Author

aminya commented Jan 26, 2022

Hi, @aminya! Thanks for giving this tool a try--and sorry things aren't working for you out of the box. It's great to have you here with us :) Pretty amazing GitHub profile you have.

Thank you so much!

I tried --all_incompatible_changes as you suggested, but it does not work. You can try the project yourself here. I used sudo ./setup/ubuntu/install_prereqs.sh to install Bazel.

@cpsauer
Copy link
Contributor

cpsauer commented Jan 26, 2022

You're very welcome!

Re --all_incompatible_changes: no no, the other way! That's a flag you almost certainly really don't want, which would implicitly set --incompatible_load_python_rules_from_bzl, which you also almost certainly don't want, and which is causing this issue and error. (Reasoning on why above and in the issues listed in the original error.)

Quick scan through that codebase shows that it does indeed set --incompatible_load_python_rules_from_bzl in //tools/bazel.rc. Try deleting that line, and lmk if the error goes away!

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