You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
arrdem
changed the title
[Bug]: py_binary not compatible with pycharm/intellij's builtin debugger
[FR]: Attaching debuggers to py_binary is difficult
May 2, 2025
It's difficult to simultaneously support debuggers which want to supervise or control debuggee startup with the needs of configuring a hermetic Python interpreter.
I suspect this will soon be broken in rules_python upstream too if you turn on the new /bin/sh based launcher script and only happens to work using the old non-hermetic python3 based launcher shim. This will continue to not work post- #551 which again uses a shell-based launcher.
Probably the only way to harmonize the two would be to teach IDEA how to request Bazel build and run a configuration of a Python program which embeds the IDEA pydev helper and treats that helper as its entrypoint.
@zfy0701, in case you can take a similar approach with PyCharm, in https://youtu.be/GTsy7IfmywQ?si=2eVPMRPLPySsjoQA&t=286@alexeagle shows how to get VSCode's Python debugger to work with a rules_py project essentially by bypassing Bazel and just using the rules_py-generated virtualenv directly, which is not difficult.
You also may be interested in liking/subscribing to https://youtrack.jetbrains.com/issue/PY-63403/Support-debugpy which tracks adding support for debugpy to PyCharm. debugpy allows IDEs to set and hit breakpoints even for Python programs started via Bazel. I've tried it with VSCode and it works like a (wait for it) charm.
What happened?
when use default debugger for py_binary
the command generated is like:
notice the last parameter /../server/server is a shell instead of python file, the debugger will fail here:
switch back to official rules_python works
Version
Development (host) and target OS/architectures:
Output of
bazel --version
: 7.4.1Version of the Aspect rules, or other relevant rules from your
WORKSPACE
orMODULE.bazel
file: MODULE.bazelLanguage(s) and/or frameworks involved: pyth
python plugin 1.0.0~ 1.3.2 behaviors similar
How to reproduce
Any other information?
No response
The text was updated successfully, but these errors were encountered: