python-poetry / python-poetry/poetry
Unable to debug with Debugpy
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 34.3k
- Forks
- 2.5k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 30
Description
-
Poetry version: 1.4.0
-
Python version: 3.10
-
OS version and name: Arch Linux
-
I am on the latest stable Poetry version, installed using a recommended method.
-
I have searched the issues of this repo and believe that this is not a duplicate.
-
I have consulted the FAQ and blog for any relevant entries or release notes.
-
If an exception occurs when executing a command, I executed it again in debug mode (
-vvvoption) and have included the output below.
Issue
Following up on this issue, for some reason nvim-dap is not being able to attach a debugger if I'm running an application using Poetry
If I run using Python directly it works, but using Poetry it automatically closes. If I run from within a Poetry shell, it bootstraps the debugger, but whenever I set breakpoints debugpy throws an error
You can see the details on the original issue.
To replicate the issue you just need to do the following:
- Create the basic setup without Poetry:
python -m venv venv
venv/bin/python -m pip install Flask
- Create a
vscode/launch.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "python",
"request": "launch",
"name": "Flask",
"module": "flask",
"args": ["--app", "foo", "run"],
"console": "integratedTerminal"
}
]
}
- Create
foo.py:
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "<p>Hello World</p>"
After this, run in your IDE, attach a debugger to it and test. You'll see that it works.
Now, do the same, but on the setup step do the setup using Poetry. After this, tried running the debugger with the Poetry setup. It would either not work (if you try using it with poetry run) or it will not be able to set any breakpoints (if you try using poetry shell)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Flask setup with a Python virtual environment and with Poetry, using the vscode/launch.json configuration and the linked nvim-dap-python issue as context. Investigate the differing behavior of poetry run and poetry shell; done means debugpy attaches successfully and breakpoints can be set in both Poetry workflows.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100