Skip to content

Running a custom task tries to load venv via stdinΒ #24897

@KUGA2

Description

@KUGA2

Hi,

I got a custom vscode task (tasks.json):

        {
            "label": "bla",
            "type": "process",
            "command": "python",
            "args": [
                "${workspaceFolder}/Scripts/Python/bla.py"
            ],
            "group": {
                "kind": "build",
                "isDefault": false
            },
        },

bla.py:

import sys

for line in sys.stdin:
    print(f"<<<{line}>>>", end='')

Running this tasks opens a new terminal window and runs it. Without any input it prints:

 *  Executing task: python C:\Users\xxxx\git\xxxx/Scripts/Python/bla.py 

& c:/Users/xxxx/git/xxxx/.venv/Scripts/Activate.ps1
<<<& c:/Users/xxxx/git/xxxx/.venv/Scripts/Activate.ps1
>>>

I was expecting not output until I type something. Then I can type and it will be repeated.
The same thing happens with cmd or in linux (bash).

This interferes with my real task. bla.py is obviously just a shortened version for reproduction.

Workarounds:

  • Run the command a second time within the same terminal window:
....
 *  The terminal process "C:\Program Files\PowerShell\7\pwsh.exe -Command python C:\Users\xxxx\git\xxxx/Scripts/Python/bla.py" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

 *  Executing task: python C:\Users\xxxx\git\xxxx/Scripts/Python/bla.py 

my input
<<<my input
>>>
  • Change interpreter: do NOT use the virtual environment

Image

  • Disable setting python.terminal.activateEnvironment

(None of those are long time viable for me and my team)

Expected:
A task should not try to source the venv, especially when it is run with "type": "process", (We could discuss "type": "shell", but nevermind).

Metadata

Metadata

Assignees

Labels

triage-neededNeeds assignment to the proper sub-team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions