1

Problem

When launching a Python debug session in VSCode using debugpy, I see three commands spawned in the integrated terminal:

  1. devbox shell - executes automatically ✓
  2. source /path/to/project/.venv/bin/activate - executes automatically ✓
  3. /usr/bin/env /path/to/project/.venv/bin/python /path/to/debugpy/launcher <port> -- -m mymodule <args> - does NOT execute automatically ✗

The first two commands run fine, but the third command (the actual debugpy launcher) just appears in the terminal without executing, causing a "Timed out waiting for launcher to connect" error. I have to manually copy and paste the command to run it.

Environment

  • OS: macOS (Apple Silicon)
  • VSCode Version: Latest
  • Python Extension: Latest
  • Python Version: 3.12
  • Environment Manager: devbox + venv

Configuration

launch.json:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Run worker",
      "type": "debugpy",
      "request": "launch",
      "preLaunchTask": "Start dev cluster",
      "module": "mymodule",
      "args": ["worker", "--task-queue", "${input:task-queue}"],
      "env": {
        "STAGE": "${input:stage}"
      },
      "console": "integratedTerminal"
    }
  ]
}

settings.json:

{
  "python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",
  "python.terminal.activateEnvironment": false,
  "terminal.integrated.automationProfile.osx": {
    "path": "/opt/homebrew/bin/zsh",
    "args": ["-l"]
  }
}

What I've Tried

  1. ✗ Added "console": "integratedTerminal" to the launch configuration
  2. ✗ Set "python.terminal.activateEnvironment": false
  3. ✗ Configured terminal automation profile with login shell

None of these resolved the issue.

Additional Observation

I noticed that in the terminal output, the third command (debugpy launcher) has a leading space before it, while the first two commands don't:

devbox shell
source /path/to/.venv/bin/activate
 /usr/bin/env /path/to/.venv/bin/python /path/to/debugpy/launcher <port> -- -m mymodule <args>

Notice the space before the third command ( /usr/bin/env). I'm not sure if this is related to the execution issue, but it's worth noting as it's the only command that fails to auto-execute.

Could this leading space be preventing the command from executing automatically, or is it just a symptom of how VSCode is sending the command to the terminal?

Question

Why is the debugpy launcher command not executing automatically when the previous shell initialization commands run fine? Is this related to how VSCode chains commands in nested shells, or is there a configuration I'm missing to ensure all three commands execute in sequence?

The commands appear to be sent to the terminal, but only the first two actually execute. What's the proper way to configure VSCode to execute the debugpy command in a terminal that has already run initialization commands?

0

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.