Skip to content

Test multiroot support for terminal activation using environment variables #21102

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

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