Repository navigation
New Integrated Terminal doesn't activate defined virtual environment for workspace #17827
Copy link
Copy link
Closed
Closed
Copy link
Labels
area-environmentsFeatures relating to handling interpreter environmentsFeatures relating to handling interpreter environmentsbugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable buginfo-neededIssue requires more information from posterIssue requires more information from poster
Description
Environment data
- VS Code version: 1.61.0
- Extension version (available under the Extensions sidebar): v2021.10.1365161279 (installed from VSIX as it is not yet available through the extensions marketplace)
- OS and version: Arch Linux with Kernel 5.14
- Python version (& distribution if applicable, e.g. Anaconda): 3.9
- Type of virtual environment used (N/A | venv | virtualenv | conda | ...): poetry
Expected behaviour
When creating a new terminal in a multi-root workspace, the correct workspace folders' virtual environment is automatically activated for the chosen workspace directory (regardless of open/active files). This should have apparently been fixed by #17595.
Actual behaviour
- if there are no open files, no virtual environment is activated
- if there is an opened file belonging to a python project, then the virtual environment of that workspace folder is activated, irrespective of the chose workspace directory
The extension output also shows an error and suggests using the --enable-proposed-api ms-python.python switch, which eliminates said error but other than that results in the same behaviour.
Steps to reproduce:
- create two project directories
test1andtest2 - initialize poetry in both directories with
poetry init - in both project directories create
.vscode/settings.jsonwhich sets thepython.pythonPath(random name generated bypoetry), similar to the following:
test1/.vscode/settings.json:
{
"python.pythonPath": "/home/user/.cache/pypoetry/virtualenvs/test1-ThPNazQP-py3.9/bin/python"
}
test2/.vscode/settings.json:
{
"python.pythonPath": "/home/user/.cache/pypoetry/virtualenvs/test2-Dk1LSx4W-py3.9/bin/python"
}
- play around with the above mentioned scenarios of (no) opened files while creating a
New Terminaland selecting a working directory.
Logs
Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)
No command line switch:
Error 2021-10-21 13:17:02: Failed to activate a workspace, Class name = y, completed in 448ms, has a falsy return value, Arg 1: <Uri:/home/user/workspace/vs-code-venv/test1>, Return Value: undefined [Error: [ms-python.python]: Proposed API is only available when running out of dev or with the following command line switch: --enable-proposed-api ms-python.python
at D (/usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:94:81006)
at v (/usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:94:80953)
at Object.get testResults [as testResults] (/usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:103:23607)
at P.activate (/home/user/.vscode-oss/extensions/ms-python.python-2021.10.1365161279/out/client/extension.js:59:75328)
at /home/user/.vscode-oss/extensions/ms-python.python-2021.10.1365161279/out/client/extension.js:52:193572
at Array.map (<anonymous>)
at y.activateWorkspace (/home/user/.vscode-oss/extensions/ms-python.python-2021.10.1365161279/out/client/extension.js:52:193563)]
Error 2021-10-21 13:17:02: Failure during activation. [Error: [ms-python.python]: Proposed API is only available when running out of dev or with the following command line switch: --enable-proposed-api ms-python.python
at D (/usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:94:81006)
at v (/usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:94:80953)
at Object.get testResults [as testResults] (/usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:103:23607)
at P.activate (/home/user/.vscode-oss/extensions/ms-python.python-2021.10.1365161279/out/client/extension.js:59:75328)
at /home/user/.vscode-oss/extensions/ms-python.python-2021.10.1365161279/out/client/extension.js:52:193572
at Array.map (<anonymous>)
at y.activateWorkspace (/home/user/.vscode-oss/extensions/ms-python.python-2021.10.1365161279/out/client/extension.js:52:193563)]
Error 2021-10-21 13:17:02: sendStartupTelemetry() failed. [Error: [ms-python.python]: Proposed API is only available when running out of dev or with the following command line switch: --enable-proposed-api ms-python.python
at D (/usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:94:81006)
at v (/usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:94:80953)
at Object.get testResults [as testResults] (/usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:103:23607)
at P.activate (/home/user/.vscode-oss/extensions/ms-python.python-2021.10.1365161279/out/client/extension.js:59:75328)
at /home/user/.vscode-oss/extensions/ms-python.python-2021.10.1365161279/out/client/extension.js:52:193572
at Array.map (<anonymous>)
at y.activateWorkspace (/home/user/.vscode-oss/extensions/ms-python.python-2021.10.1365161279/out/client/extension.js:52:193563)]
Starting Jedi language server.
When using the proposed switch --enable-proposed-api ms-python.python:
> conda info --json
> "poetry env list --full-path"
cwd: ~/workspace/vs-code-venv/test1
> "poetry env list --full-path"
cwd: ~/workspace/vs-code-venv/test2
> ~/.cache/pypoetry/virtualenvs/test1-ThPNazQP-py3.9/bin/python ~/.vscode-oss/extensions/ms-python.python-2021.10.1365161279/pythonFiles/interpreterInfo.py
Python interpreter path: ~/.cache/pypoetry/virtualenvs/test1-ThPNazQP-py3.9/bin/python
> /bin/python ~/.vscode-oss/extensions/ms-python.python-2021.10.1365161279/pythonFiles/interpreterInfo.py
> /sbin/python ~/.vscode-oss/extensions/ms-python.python-2021.10.1365161279/pythonFiles/interpreterInfo.py
> /usr/bin/python ~/.vscode-oss/extensions/ms-python.python-2021.10.1365161279/pythonFiles/interpreterInfo.py
> /usr/sbin/python ~/.vscode-oss/extensions/ms-python.python-2021.10.1365161279/pythonFiles/interpreterInfo.py
> ~/.cache/pypoetry/virtualenvs/test2-Dk1LSx4W-py3.9/bin/python ~/.vscode-oss/extensions/ms-python.python-2021.10.1365161279/pythonFiles/interpreterInfo.py
Starting Jedi language server.
> conda --version
When opening/switching between files:
Python interpreter path: ~/.cache/pypoetry/virtualenvs/test2-Dk1LSx4W-py3.9/bin/python
Python interpreter path: ~/.cache/pypoetry/virtualenvs/test1-ThPNazQP-py3.9/bin/python
EDIT: typo
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area-environmentsFeatures relating to handling interpreter environmentsFeatures relating to handling interpreter environmentsbugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable buginfo-neededIssue requires more information from posterIssue requires more information from poster
Activity
kimadeline commentedon Oct 21, 2021
Hi @lluetcke-ct,
Which VSIX did you install? Can you try switching to the Insiders version of the Python instead?
toastedonion commentedon Oct 22, 2021
I installed the VSIX from the releases: https://github.com/microsoft/vscode-python/releases/download/2021.10.1365161279/ms-python-release.vsix
Thanks, I tried it and the daily as well as the weekly insiders channel are working for me.
kimadeline commentedon Oct 22, 2021
Sounds good. The change introduced by #17595 will be released as part of the 2021.11 release, closing.