Repository navigation
Creating new Integrated Terminal doesn't take selected workspace into account when activating environment #15522
Copy link
Copy link
Closed
Labels
area-terminalbugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable buggood first issueverifiedVerification succeededVerification succeeded
Milestone
Description
Environment data
- Version: 1.54.0-insider (user setup)
- Commit: e590188
- Date: 2021-02-26T20:39:10.253Z
- Electron: 11.3.0
- Chrome: 87.0.4280.141
- Node.js: 12.18.3
- V8: 8.7.220.31-electron.0
- OS: Windows_NT x64 10.0.19042
- Python version (& distribution if applicable, e.g. Anaconda): python3.8
- Type of virtual environment used (N/A | venv | virtualenv | conda | ...): Pipenv and just venv
-- Relevant/affected Python packages and their versions: XXX
-- Relevant/affected Python-related VS Code extensions and their versions: XXX
-- Value of thepython.languageServersetting: XXX
Expected behaviour
This is while working with multiple projects in a workspace.
Up until recently, just a day or two ago, Selecting a "New Integrated Terminal" worked perfectly. It asks "Select current working directory for new terminal". The terminal would perfectly pick up the correct venv based on the folder's settings namely python.pythonPath.
Actual behaviour
Now, it seems to pick the venv based on the last file or editor only. If I click a workspaceX file, it uses the venv for workspaceX no matter what "Select current working directory for new terminal" directory is chosen in the prompt. :(
Steps to reproduce:
Here is a minimal example.
- Create new project folder test1.
- Create new project folder test2.
- cd test1; mkdir venv; python -m venv venv; touch test1.py; cd ..
- cd test2; mkdir venv; python -m venv venv; touch test2.py; cd ..
- Save project settings.
mkdir test1/.vscode
cat > test1/.vscode/settings.json
{
"python.pythonPath": "venv/bin/python"
}
mkdir test2/.vscode
cat > test2/.vscode/settings.json
{
"python.pythonPath": "venv/bin/python"
}
- Save workspace
cat > workspace.code-workspace
{
"folders": [
{
"path": "test1"
},
{
"path": "test2"
}
],
"settings": {}
}
- Now open the workspace. Select test2.py. New Integrated Terminal -> Select test1 -> you get:
source /home/jchang/proj/tests/bugreport/test2/venv/bin/activate
This should be using test1 not test2!!! This used to work up until the last day or two! :(
Reactions are currently unavailable
Metadata
Metadata
Labels
area-terminalbugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable buggood first issueverifiedVerification succeededVerification succeeded
Activity
karrtikr commentedon Mar 2, 2021
Hi jchang10 👋 Please provide the logs as mentioned in the issue template, also what extension version are you using?
Logs
Output for
Pythonin theOutputpanel (View→Output, change the drop-down the upper-right of theOutputpanel toPython)jchang10 commentedon Mar 2, 2021
Hi. Sorry. ms-python version ms-python.python-2021.2.582707922. I am on the nightly build.
Below is my entire python log output after a window reload. Not seeing anything major.
The weird thing is that this is what my terminal windows shows after New Terminal. I only have test2.py showing in the editor. I do New Terminal -> Select test1 as my working dir, and this is what I get. It correctly opens a terminal with the directory in test1, but the environment is from test2!
karrtikr commentedon Mar 2, 2021
Thanks for the logs, I'll try to reproduce and get back to you soon.
karrtikr commentedon Mar 22, 2021
jchang10 I'm able to reproduce this issue, thanks! Although that is how it always used to work.
vscode-python/src/client/terminals/activation.ts
Lines 44 to 48 in c11009f
As the comment states we were waiting on VSCode for the fix on microsoft/vscode#63052. Looks like it has been fixed, so we'll need to change that line to get
terminal.creationOptions.cwdinstead of the active resource when possible.Passing the following as
resourceinstead should fix the issue:You're welcome to fix it as well.
14 remaining items
added microsoft#15522 issue fix and contributor name
Worked on issue microsoft#15522
worked on microsoft#15522 issue
added microsoft#15522 issue fix and contributor name
Creating new Integrated Terminal doesn't take selected workspace into…
Creating new Integrated Terminal doesn't take selected workspace into…
Creating new Integrated Terminal doesn't take selected workspace into…
karrtikr commentedon Oct 20, 2021
Fixed with #17595