Skip to content

Test multiroot support for terminal activation using environment variables #21102

Closed

Description

@karrtikr

Refs: #21101

Complexity: 5

Create Issue


Requirements

Similar to #20884 hence preassigning. Make sure to check the (new) requirements.

  • Python extension pre-release
  • Latest VSCode Insiders
  • Virtual or conda environment
    • Install conda via: https://conda.io/projects/conda/en/latest/user-guide/install/index.html. Make sure it's on PATH during installation.
      • Run conda init to initialize the shell.
      • (new) Run conda config --set auto_activate_base False.
      • Restart shell for changes to take effect.
      • Create conda env using conda create -n <name> python -y.
    • Use python -m venv <name> to create virtual envs.

Verification

  • Add following to user settings and reload window:
"python.experiments.optInto": ["pythonTerminalEnvVarActivation"]
  • Use a workspace with multiple workspace folders. (File -> Add folder to workspace...)

  • For each workspace folder:

    • Activate Python extension by opening a Python file.
    • Select a virtual or conda environment using Python: Select Interpreter command. This should be different for each folder.
  • Open multiple terminals for each workspace folder:
    image

  • For each workspace folder, w:

    • Make sure terminal for w is activated using the selected environment for w. Run the following in terminal:
      python -c"import sys;print(sys.executable)"
      
    • Output should contain the path to interpreter selected. For eg. for .venv created via python -m venv .venv it looks something like:
      C:\Users\karraj\OneDrive - Microsoft\Desktop\folders\crap\.venv\Scripts\python.exe
      
    • Hover over the tab title, note Python has a description for which env is activated next to it:

    image

    • Run some random commands in the terminal, then change environment using Python: Select Interpreter command, a warning sign should appear to the right of terminal with new env changes that're about to be made:

    image

    • Click show environment contributions highlighted above, make sure the environment variables are for the right environment:

      image

Activity

  1. aiday-mar commented on Apr 25, 2023

    @aiday-mar

    Hi Kartik Raj (@karrtikr), great work here. I have just been testing the fix. I opened two workspace folders into which I placed a python file each and selected different interpreters for each. I created two terminals per workspace folder. When I change the interpreter for one of the folders, one of the terminal labels becomes yellow, but not the second one, despite them being associated to the same folder. Upon clicking on the show contributions button, the same file is opened for both terminals. I was wondering if this is intended?

    Screen.Recording.2023-04-25.at.11.40.15.mov
  2. karrtikr commented on Apr 25, 2023

    @karrtikr
    Author

    Aiday Marlen Kyzy (@aiday-mar) Thanks for identifying this! it does look like either a limitation of the API or a bug.

    but not the second one, despite them being associated to the same folder.

    ⚠️ signs only appears next to terminals which are dirty, as they require a relaunch to update the envs. The second has not been interacted with yet, so envs are updated without the need for relaunching it, but it seems that the description is not updated microsoft/vscode#180851.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions