|
| 1 | +# How to use a #Debugger with `langgraph dev` in [[PyCharm]] |
| 2 | + - ## Partially Working |
| 3 | + - ### Creating a [[PyCharm/Run Configuration]] for `langgraph-dev --allow-blocking` |
| 4 | + - [[langgraph/GitHub/Discussion/25/04/How to use langgraph dev in a PyCharm Debugger]] |
| 5 | + - #### [[My Notes]] |
| 6 | + - Marked as "partially working" because the `--allow-blocking` argument is needed because [[pydevd]] uses blocking operations to resolve symlinks to files, which triggers [[langgraph]]'s detection using [[Py/Lib/blockbuster]] |
| 7 | + - #### PyCharm Run Configuration parameters |
| 8 | + - **Run Configuration Type** - Python |
| 9 | + - **Virtual Environment** - Select your project's virtual environment |
| 10 | + - **Run Configuration Subtype** - `script` |
| 11 | + - **Script Path**: absolute path to the `langgraph` executable within the virtualenv, found with `which langgraph` |
| 12 | + - (anyone know how to make this more dynamic? just putting in `langgraph` yields `FileNotFoundError: [Errno 2] No such file or directory: 'langgraph'` |
| 13 | + - **Script Parameters**: `dev --allow-blocking` |
| 14 | + - no need for `--debug-port`, which is for [[Py/debugpy]] instead of PyCharm's [[pydevd]] |
| 15 | + - ## Not Working |
| 16 | + - ### Attach to Process |
| 17 | + - #### 1 - `langgraph dev` in a terminal, then use [[PyCharm/Debug/Attach to Process]] |
| 18 | + - #### To reproduce |
| 19 | + - in a terminal - run `langgraph dev` |
| 20 | + - initiate [[PyCharm/Debug/Attach to Process]] |
| 21 | + - #### Expected Behavior - PyCharm is able to debug an external process |
| 22 | + - #### Actual Behavior - `error: Execution was interrupted, reason: signal SIGSTOP`. |
| 23 | + - ``` |
| 24 | + Attaching to a process with PID=85,887 |
| 25 | + /path/to/python/env/bin/python /Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd_attach_to_process/attach_pydevd.py --port 59663 --pid 85887 |
| 26 | + Running: lldb --no-lldbinit --script-language Python -o 'process attach --pid 85887' -o 'command script import "/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd_attach_to_process/linux_and_mac/lldb_prepare.py"' -o 'load_lib_and_attach "/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd_attach_to_process/attach.dylib" 0 "import sys;sys.path.append(\"/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev\");sys.path.append(\"/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd_attach_to_process\");import attach_script;attach_script.attach(port=59663, host=\"127.0.0.1\", protocol=\"\", debug_mode=\"\");" 0' -o 'process detach' -o 'script import os; os._exit(1)' |
| 27 | + (lldb) process attach --pid 85887 |
| 28 | + Process 85887 stopped |
| 29 | + * thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP |
| 30 | + frame #0: 0x00000001935353c8 libsystem_kernel.dylib`__semwait_signal + 8 |
| 31 | + libsystem_kernel.dylib`__semwait_signal: |
| 32 | + -> 0x1935353c8 <+8>: b.lo 0x1935353e8 ; <+40> |
| 33 | + 0x1935353cc <+12>: pacibsp |
| 34 | + 0x1935353d0 <+16>: stp x29, x30, [sp, #-0x10]! |
| 35 | + 0x1935353d4 <+20>: mov x29, sp |
| 36 | + Target 0: (python3.12) stopped. |
| 37 | + Executable module set to "/path/to/python/3.12.1/bin/python3.12". |
| 38 | + Architecture set to: arm64-apple-macosx-. |
| 39 | + (lldb) command script import "/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd_attach_to_process/linux_and_mac/lldb_prepare.py" |
| 40 | + (lldb) load_lib_and_attach "/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd_attach_to_process/attach.dylib" 0 "import sys;sys.path.append(\"/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev\");sys.path.append(\"/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd_attach_to_process\");import attach_script;attach_script.attach(port=59663, host=\"127.0.0.1\", protocol=\"\", debug_mode=\"\");" 0 |
| 41 | + /Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd_attach_to_process/attach.dylib |
| 42 | + success |
| 43 | + import sys;sys.path.append("/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev");sys.path.append("/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd_attach_to_process");import attach_script;attach_script.attach(port=59663, host="127.0.0.1", protocol="", debug_mode=""); |
| 44 | + error: error: Execution was interrupted, reason: signal SIGSTOP. |
| 45 | + The process has been returned to the state before expression evaluation. |
| 46 | + (lldb) process detach |
| 47 | + Process 85887 detached |
| 48 | + (lldb) script import os; os._exit(1) |
| 49 | + Traceback (most recent call last): |
| 50 | + File "/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd_attach_to_process/attach_pydevd.py", line 79, in <module> |
| 51 | + main(process_command_line(sys.argv[1:])) |
| 52 | + File "/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd_attach_to_process/attach_pydevd.py", line 74, in main |
| 53 | + add_code_to_python_process.run_python_code( |
| 54 | + File "/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd_attach_to_process/add_code_to_python_process.py", line 533, in run_python_code_mac |
| 55 | + subprocess.check_call(' '.join(cmd), shell=True, env=env) |
| 56 | + File "/path/to/python/3.12.1/lib/python3.12/subprocess.py", line 413, in check_call |
| 57 | + raise CalledProcessError(retcode, cmd) |
| 58 | + subprocess.CalledProcessError: Command 'lldb --no-lldbinit --script-language Python -o 'process attach --pid 85887' -o 'command script import "/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd_attach_to_process/linux_and_mac/lldb_prepare.py"' -o 'load_lib_and_attach "/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd_attach_to_process/attach.dylib" 0 "import sys;sys.path.append(\"/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev\");sys.path.append(\"/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd_attach_to_process\");import attach_script;attach_script.attach(port=59663, host=\"127.0.0.1\", protocol=\"\", debug_mode=\"\");" 0' -o 'process detach' -o 'script import os; os._exit(1)'' returned non-zero exit status 1. |
| 59 | + ``` |
| 60 | + - #### 2 - `langgraph dev` in a [[PyCharm/Run Configuration]], then use [[PyCharm/Debug/Attach to Process]] |
| 61 | + - setup - same as 1, except running `langgraph dev` using a run configuration |
| 62 | + - same result as 1 |
| 63 | + - |
0 commit comments