I have the VSCode integrated terminal set to my Git bash, using this in settings.json:
"terminal.integrated.automationShell.windows": "${env:LOCALAPPDATA}\\Programs\\Git\\bin\\bash.exe",
I have the Python interpreter selected, using "Python: Select Interpreter" to the interpreter in my virtual environment - when I bring it up, it shows:
Current: C:\work_dir\projdir\py_env\venvdir\Scripts\python.exe
When go to the debugger and start the program (with or without debugging), the bash terminal opens, and this command is issued in the terminal:
/usr/bin/env C:\\work_dir\\projdir\\py_env\\venvdir\\Scripts\\python.exe c:\\Users\\userid\\.vscode\\extensions\\ms-python.python-2020.9.111407\\pythonFiles\\lib\\python\\debugpy\\launcher 61892 -- c:\\work_dir\\projdir\\myscript.py -arg1 arg2
(where the args come from my launch.json)
Then, after the script finishes running, this command is issued in the terminal:
& C:/work_dir/projdir/py_env/venvdir/Scripts/Activate.ps1
Which is the PowerShell way of activating the venv, I guess.
Which, of course, results in:
bash: syntax error near unexpected token `&'
The script actually runs fine.
Why is it that, after running the script in the bash terminal, VSCode issues a command in the terminal to try to activate the venv in a PowerShell way?
This is doubly weird: That it attempts a PowerShell command in a bash terminal, and that it attempts to activate the venv after and not before the script.