You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Show create venv when users attempt to install packages to global #41
When a user installs packages through the extension, we should check the environment before running the installation.
If the target is a global environment, prompt the user to:
a) Create new virtual environment with the requested packages (quickCreate)
b) Use an existing virtual environment, then install the packages
c) Continue globally, keeping the original installation target
Dismissing the prompt should cancel the installation
Requests targeting a virtual environment should proceed normally
Sharing media and context from merged PR #1842 for verification:
This pull request introduces a new workflow for package installation that helps users avoid installing packages into global Python environments by offering alternatives, such as creating or selecting a virtual environment. The changes affect the package management commands, their APIs, and the handling of package versions. Additionally, the codebase has been refactored for clarity and improved error handling, especially for Python 2 environments.
Global Environment Package Installation Workflow:
Added a new helper (selectPackageManagementEnvironment in src/features/nonGlobalPackageInstallationEnvironment.ts) that prompts users to create or select a virtual environment when attempting to install packages into a global environment, reducing the risk of polluting global Python installations.
Updated the main API (managePackages in src/extensionApi.ts) and package version management command (managePackageVersion in src/features/envCommands.ts) to use this helper, ensuring that package installations prompt users appropriately and respect their choices. [1] [2] [3]
Error Handling and Compatibility:
Improved error handling in the pip package manager to explicitly reject operations on Python 2 environments, preventing deprecated usage.
Refactoring and Code Quality:
Refactored imports and formatting in several files for clarity and maintainability, and updated test stubs to cover the new workflow. [1] [2] [3]
These changes collectively improve package management UX and reliability, especially around global environment safety.
Activity
edvilme commentedon Sep 30, 2026
Proposed workflow
When a user installs packages through the extension, we should check the environment before running the installation.
If the target is a global environment, prompt the user to:
a) Create new virtual environment with the requested packages (quickCreate)
b) Use an existing virtual environment, then install the packages
c) Continue globally, keeping the original installation target
Dismissing the prompt should cancel the installation
Requests targeting a virtual environment should proceed normally
vs-code-engineering commentedon Oct 29, 2026
Sharing media and context from merged PR #1842 for verification:
This pull request introduces a new workflow for package installation that helps users avoid installing packages into global Python environments by offering alternatives, such as creating or selecting a virtual environment. The changes affect the package management commands, their APIs, and the handling of package versions. Additionally, the codebase has been refactored for clarity and improved error handling, especially for Python 2 environments.
Global Environment Package Installation Workflow:
selectPackageManagementEnvironmentinsrc/features/nonGlobalPackageInstallationEnvironment.ts) that prompts users to create or select a virtual environment when attempting to install packages into a global environment, reducing the risk of polluting global Python installations.managePackagesinsrc/extensionApi.ts) and package version management command (managePackageVersioninsrc/features/envCommands.ts) to use this helper, ensuring that package installations prompt users appropriately and respect their choices. [1] [2] [3]Error Handling and Compatibility:
Refactoring and Code Quality:
These changes collectively improve package management UX and reliability, especially around global environment safety.
Source PR: #1842
Prompt for non-global environments when managing packages (microsoft#…