Skip to content

Parent process venv is not passed through to python subprocesses when using internalConsole #1678

Open
@edwardpeek-crown-public

Description

@edwardpeek-crown-public

Configuring "console": "internalConsole" for a launch target causes Python subprocesses spawned by the main debug process to not have their venv inherited correctly.

Repro. steps:

  1. Create a venv and install cowsay
  2. Open VS Code in the venv parent dir
  3. Create files as follows:

test.py:

import subprocess
stdout = subprocess.check_output(["python", "-m", "cowsay", "-t", "test"])
print(stdout.decode())

.vscode/launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python Debugger: test.py",
            "type": "debugpy",
            "request": "launch",
            "program": "test.py",
            "console": "internalConsole", // Doesn't work
//            "console": "integratedTerminal", // Works
        }
    ]
}
  1. Launch the debug target

Actual outcome

  • Dialog box with "Server disconnected unexpectedly" displayed
  • "No module named cowsay" printed in debug console

Expected outcome

  • Subprocess runs without error

Notes

The underlying cause seems to be that the PATH and VIRTUAL_ENV env vars are not inherited correctly in spawned subprocesses when they are intercepted for debugging.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds reproIssue has not been reproduced yet

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions