1

I'm using Poetry to manage my virtual environments for Python and I'm using Vimspector as a debugger plugin for Vim.

How can I use the Poetry venv when starting debugging?

I'm thinking that all that has to be done is to run the command poetry shell on the terminal session that the Vimspector will use, but I haven't out how to do this.

Any solution?

2 Answers 2

2

I think you should create your own adapter in your vimspector configuration.

You can find help in this documentation.

Here a configuration I use to run vimspector with poetry and debugpy:

{
  "adapters": {
    "poetry-debugpy": {
      "port": "5678",
      "host": "localhost",
      "launch": {
        "remote": {
          "host": "localhost",
          "runCommand": [
            "poetry", "run",
            "python3", "-m", "debugpy",
            "--listen", "0.0.0.0:5678",
            "--wait-for-client",
            "%CMD%"
          ]
        }
      }
    }
  },
  "configurations": {
    "python debug": {
      "adapter": "poetry-debugpy",
      "breakpoints": {
        "exception": {
          "all": "Y",
          "uncaught": "Y"
        }
      },
      "configuration": {
        "name": "Python: Attach",
        "type": "python",
        "request": "attach"
      }
    }
  }
}
1
1

For those that trying to find an answer, creating a specific adapter is not the best approach.

I asked at Gitter of Vimspector and the best way is to specify the path of Python executable, which can be found using which python when inside Poetry.

That is, at the configuration (and not at the adapter part) one has to specify:

'python': 'path/to/python/inside/poetry`

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.