Skip to content

Test: Environment activation using shell startup #226

Closed
@karthiknadig

Description

@karthiknadig

Refs: #227

Complexity: 4

Create Issue


Requirements

Use extension build from here: https://github.com/microsoft/vscode-python-environments/actions/runs/14048386114/artifacts/2812047113

NOTE This is NOT shipped in pre-release because if this has issues it can leave users shell in a bad state.

Validation

NOTE the following steps will change your shell startup scripts. Please take a backup of your shell startup.

Setup

  1. Do this external to VS Code. Setup a directory with a python file and an environment. Creating python environment can be done by running python -m venv .venv from the workspace directory.
  2. Open that workspace and install the above extension. Make sure both python extension and python envs extension are activated.
  3. Note: You may need to reload, if you already had python extension.
  4. Go to settings and change this python-envs.terminal.autoActivationType setting to shellStartup.
  5. That should show you this:
    Image
  6. Update Shell Profile will apply changes to all shell profiles listed in the modal.
  7. See Activation using Shell Startup #227 for details on the changes made.

Things to Check

  1. Opening a terminal in vscode should have the virtual environment activated. A test is to print VRITUAL_ENV env variable for your shell. like echo $VIRTUAL_ENV. Your prompt may also show .venv.
  2. Reloading VS Code should give you activated terminals. you should not see any modals asking you to update shell startup. This is a one time change.
  3. Terminal shells outside of VS Code should not have any impact from this change.
  4. This should also work with any prompt customization, like starship, oh-my-posh, etc.
  5. There is a command to revert all the changes: Python Envs: Revert Shell Startup Script Changes. running this should also switch you back to command mode in the python-envs.terminal.autoActivationType.
  6. Revert should remove changes. Except in cmd, it will only remove activation code. Any changes to registry will remain. But it will not affect cmd execution.
  7. After reverting you should get command activation. That is opening a terminal in VS Code will cause a command to be sent to it.
  8. Switching the setting from shellStartup to command should NOT revert the changes made to various shells. But it should change the environment contributed to the terminals in VS Code (i.e., you should see warning for relaunch on terminal tabs)

Windows

  • cmd
  • Powershell 5
  • pwsh 7.5
  • gitbash
  • [Optional] nu

Mac

  • pwsh 7.5
  • zsh
  • bash
  • fish
  • nu

Linux

  • pwsh 7.5
  • zsh
  • bash
  • fish
  • nu

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions