Skip to content

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

Closed

Description

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

Activity

  1. dahelg commented on Jun 20, 2019

    @dahelg

    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"
    		}
    	]
    }
  2. Jordan-Kowal commented on Jun 20, 2019

    @Jordan-Kowal

    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.

  3. kimadeline commented on Sep 28, 2019

    @kimadeline

    Hi Helge Drews (@dahelg) and Jordan Kowal (@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!

  4. karrtikr commented on Nov 26, 2019

    @karrtikr

    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

  5. DonJayamanne commented on Nov 26, 2019

    @DonJayamanne
    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).

  6. karrtikr commented on Nov 26, 2019

    @karrtikr

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

  7. DonJayamanne commented on Nov 26, 2019

    @DonJayamanne
    Author

    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.
  8. karrtikr commented on Nov 26, 2019

    @karrtikr

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

  9. DonJayamanne commented on Nov 26, 2019

    @DonJayamanne
    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).

  10. karrtikr commented on Nov 26, 2019

    @karrtikr

    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.

  11. schperplata commented on Jan 4, 2021

    @schperplata

    Don Jayamanne (@DonJayamanne) Kartik Raj (@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?

  12. schperplata commented on Mar 9, 2021

    @schperplata

    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.

  13. karrtikr commented on Mar 9, 2021

    @karrtikr

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

  14. karrtikr commented on Oct 20, 2021

    @karrtikr

    Closed as dup of #15522

  15. locked as resolved and limited conversation to collaborators on Nov 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-environmentsFeatures relating to handling interpreter environmentsarea-terminalbugIssue identified by VS Code Team member as probable bugverifiedVerification succeeded

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions