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

target <target @@hedron_compile_commands//:_refresh_all> does not have rules_python PyRuntimeInfo or builtin PyRuntimeInfo #163

Closed
axbycc-mark opened this issue Jan 25, 2024 · 7 comments

Comments

@axbycc-mark
Copy link

Following the setup, I ran bazel run @hedron_compile_commands//:refresh_all and got this error

ERROR: C:/users/marki/_bazel_marki/fmtahulu/external/hedron_compile_commands/BUILD:7:25: in _transition_py_binary rule @@hedron_compile_commands//:refresh_all:
Traceback (most recent call last):
        File "C:/users/marki/_bazel_marki/fmtahulu/external/rules_python/python/config_settings/transition.bzl", line 78, column 13, in _transition_py_impl
                fail("target {} does not have rules_python PyRuntimeInfo or builtin PyRuntimeInfo".format(target))
Error in fail: target <target @@hedron_compile_commands//:_refresh_all> does not have rules_python PyRuntimeInfo or builtin PyRuntimeInfo
ERROR: C:/users/marki/_bazel_marki/fmtahulu/external/hedron_compile_commands/BUILD:7:25: Analysis of target '@@hedron_compile_commands//:refresh_all' failed
ERROR: Analysis of target '@@hedron_compile_commands//:refresh_all' failed; build aborted
INFO: Elapsed time: 16.125s, Critical Path: 0.06s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
ERROR: Build failed. Not running target

Bazel version 7.0.2
Windows 10 x86_64

@cpsauer
Copy link
Contributor

cpsauer commented Jan 27, 2024

Hi, @axbycc-mark! Thanks for giving the tool a try and for writing in.

I....am not sure based on that description and haven't been able to reproduce it on my machine. One guess if you're importing via the workspace: Could you try bringing in this tool first (rather than at the end of the file)? My first guess is that maybe some other dependency is bringing in an old version of rules_python.

If that doesn't work, could I ask you to explore some more and maybe give me some more details?

Thanks,
Chris

@axbycc-mark
Copy link
Author

I found out the error occurs even in an otherwise empty project, which I have uploaded below.

https://github.com/axbycc-mark/hedron-compile-commands-repro/tree/master

Is it because I am using a WORKSPACE file instead of using the new module system? Thanks for your help, I am excited to get this working!

@cpsauer
Copy link
Contributor

cpsauer commented Jan 30, 2024

Phew, yikes. Thanks @axbycc-mark.

I'm guessing it must be a Windows-specific bazelbuild/rules_python issue, then, since that test project runs cleanly on Mac and the error doesn't seem to make a lot of sense...it's rules_python complaining about it's own py_binary rule?

Here's what I think we should do: Would you be down to report this to the folks over at bazelbuild/rules_python, cc me? (It looks like they've got other windows breakages over there....) Then would you be down test with rules python downgraded (use this tool's commit 4d56714)? If that works, great, temporarily. And if not let's zip you back to 6d58fa6, just to make sure all was working before moving to rules python. I'm so sorry this has caused a headache; we tried to switch to Bazel's new python infrastructure to not reply on system python and to be able to use packages, but they've had quite a few bugs.

@axbycc-mark
Copy link
Author

4d56714 failed with the same error.
6d58fa6 successfully generated a compile_commands.json after I made dummy BUILD file building a simple cc_library. I had to update my WORKSPACE following the previous install instructions


load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")


# Hedron's Compile Commands Extractor for Bazel
# https://github.com/hedronvision/bazel-compile-commands-extractor
http_archive(
    name = "hedron_compile_commands",

    # Replace the commit hash (daae6f40adfa5fdb7c89684cbe4d88b691c63b2d) in both places (below) with the latest (https://github.com/hedronvision/bazel-compile-commands-extractor/commits/main), rather than using the stale one here.
    # Even better, set up Renovate and let it do the work for you (see "Suggestion: Updates" in the README).
    url = "https://github.com/hedronvision/bazel-compile-commands-extractor/archive/daae6f40adfa5fdb7c89684cbe4d88b691c63b2d.tar.gz",
    strip_prefix = "bazel-compile-commands-extractor-daae6f40adfa5fdb7c89684cbe4d88b691c63b2d",
    # When you first run this tool, it'll recommend a sha256 hash to put here with a message like: "DEBUG: Rule 'hedron_compile_commands' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = ..."
)
load("@hedron_compile_commands//:workspace_setup.bzl", "hedron_compile_commands_setup")
hedron_compile_commands_setup() 

I hope that helps.

@axbycc-mark
Copy link
Author

Not sure what to put for the python_rules version in my upstream issue, can you let me know?

@cpsauer
Copy link
Contributor

cpsauer commented Jan 31, 2024

Thanks so much for reporting and helping. Replied over there. Sorry again about the headache here. Importance of that test case I was asking you to run is to make sure they aren't just wholly broken on windows. We'll knock this out if we work together :)

cpsauer added a commit that referenced this issue Feb 1, 2024
Mostly reverts 0e5b1aa

Tracking restoration at #168

Please see
- #163
- bazelbuild/rules_python#1732
- #165
- (rules_python issue to come)
- #166
- bazelbuild/rules_python#1169
@cpsauer
Copy link
Contributor

cpsauer commented Feb 1, 2024

Reverted rules_python in 0b821b7. Tracking restoration in #168.

That avoids this for now, but seriously, worth our working with them to get it fixed for future use; this'll be important in the future.

(Just holler if you want me to reopen.)

Thanks again for helping leave things better than you found them!

@cpsauer cpsauer closed this as completed Feb 1, 2024
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