Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto activation of environments does not work with multi root workspaces #3325

Closed
DonJayamanne opened this issue Nov 13, 2018 · 14 comments
Closed
Assignees
Labels
area-environments Features relating to handling interpreter environments area-terminal bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Milestone

Comments

@DonJayamanne
Copy link

DonJayamanne commented Nov 13, 2018

Not a dup of #1476

  • Create two workspace folders
  • One with python 3, other with py 2
  • Ensure you have no files opened in the file tab
  • Create a new terminal (using + on terminal panel), extension doesn't activate the terminal based on workspace folder for which VSC created a terminal

We need VSC API to provide workspace folder for which the term was created.

Upstream microsoft/vscode#63052

@dahelg
Copy link

dahelg commented Jun 20, 2019

I have a very similar issue with a multi-root workspace containing two folders. Each of the folders has it's own venv. But for both folders only the venv which is set for the first folder starts in the terminal.
I also found, if I change the positions of the folder path within the <multiroot-workspacename>.code-workspace file, always the venv of the first folder is started.

{
	"folders": [
		{
			"path": "myfolder1"
		},
		{
			"path": "myfolder2"
		}
	]
}

This example would start the venv1 of myfolder1 which is set in it's .vscode/settings.json with "python.pythonPath": "venv1/bin/python", even if I run a file from myfolder2. By the way, the default setting "python.terminal.activateEnvironment": true is active.

If I change my <multiroot-workspacename>.code-workspace file to the following, everything is run with the venv2 of myfolder2 instead.

{
	"folders": [
		{
			"path": "myfolder2"
		},
		{
			"path": "myfolder1"
		}
	]
}

@Jordan-Kowal
Copy link

Yeah, I have the same issue whenever I have a workspace with several virtualenv, even if I specify path folders in the settings.json, VSCode will always activate the first one in the terminal. A temporary workaround I found is having only one python/venv per workspace, and using the Project Manager to switch between projects.

@kimadeline
Copy link

kimadeline commented Sep 28, 2019

Hi @dahelg and @Jordan-Kowal 👋 would you mind trying the latest Insiders version of the extension (2019.10.0.38992-dev and onwards) ? #7534 just got merged (for issue #6282) and may help with environment activation for multi-root workspaces.

Thanks!

@karrtikr
Copy link

I think this issue maybe fixed. I tried creating the terminal in multiworkspace scenario, and it asks me this before creating the terminal. It then correctly activates the correct environment based on that.

image

@DonJayamanne
Copy link
Author

Create a new terminal, extension doesn't activate the terminal based on workspace folder for which VSC created a terminal

Create a terminal by clicking on + on the terminal window (i.e. do not use out command).

@karrtikr
Copy link

That's what I did. But I don't see this issue.

@DonJayamanne
Copy link
Author

DonJayamanne commented Nov 26, 2019

Ok, not sure how it works for you.
This is what i did:

  • Create workspace folder a, add a virtual environment named helloA
  • Create workspace folder b, add a virtual environment named helloB
  • Create python files in both folders and ensure you select helloA as the interpreter for folder a, similarly helloB for b.
  • Create a terminal for a, then helloA should be activated in terminal
  • Create a terminal for b, then helloB should be activated in terminal
    • This does not work.

@karrtikr
Copy link

Yes, I did exactly the same thing. I am using the latest VS Code insiders and extension version. Asking @kimadeline to repro it.

@DonJayamanne
Copy link
Author

I'm on latest insider and extension as well, & it doesn't work for me.
Please ensure you close all files when opening a terminal (there's no mention of having files opened here).

@karrtikr
Copy link

Oh right, I had files opened in the tab. I closed all the tabs and I am able to repro this. Sorry for the confusion.

@schperplata
Copy link

@DonJayamanne @karrtikr
I am not sure if this is a separate issue, but there sure are some similarity: I have one VSC workspace with multiple folders. There is no settings.json or .vscode folder(s), just a single .code-workspace file with all settings, launch and other workspace settings. Here is my folder structure:

  • folder1/:
    • <package 1>/
    • wks/:
      • dev.code-workspace
      • venv/
  • folder2/:
    • <package 2>/
  • folder3/:
    • <package 3>/
      ...

I want to use venv from folder1 in all folders/packages added to dev.code-workspace, so I set workspace-wide python interpretter setting to python in venv. As it currently works, venv is detected, selected and activated properly for folder1, but not for others. Others report missing python interpretter path setting and therefore also doesn't work.
Am I doing something wrong or is this a bug?

@schperplata
Copy link

ping <someone>
I am wondering if there is any clarification on this subject? I am really starting to wonder I am doing something wrong since no other is reporting/thumbing up this issue.

@karrtikr
Copy link

karrtikr commented Mar 9, 2021

Please open up a new issue with the details and we can help you. We don't track new issues in comments.

@karrtikr
Copy link

Closed as dup of #15522

@karrtikr karrtikr added this to the October 2021 milestone Oct 20, 2021
@karrtikr karrtikr self-assigned this Oct 20, 2021
@karrtikr karrtikr added the verified Verification succeeded label Oct 25, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-environments Features relating to handling interpreter environments area-terminal bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

9 participants