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
Deleting .venv outside VS Code leaves the deleted interpreter selected #1886
Problem: Deleting a workspace virtual environment outside VS Code (for example rm -rf .venv in a terminal) leaves it selected. The status bar keeps showing the deleted .venv, and Run, terminals and Pylance keep pointing at an interpreter that no longer exists until the window is reloaded or environments are refreshed manually.
The venv manager refreshes on changes to **/activate files. VS Code reports a deleted folder only as the folder itself (events for the files in it are dropped), so deleting the whole venv folder never matches.
Environment: Windows 11, VS Code 1.140.0, extension main @ 52f6ace.
Before:
Steps to verify fix:
Open a folder that has a .venv and open a .py file; verify the status bar shows .venv.
Delete the folder from a terminal (rm -rf .venv or rmdir /s /q .venv).
Verify within a few seconds the status bar switches to another interpreter.
Recreate it (python -m venv .venv) and verify the status bar switches back to .venv.
Delete an unrelated folder in the workspace and verify the selection does not change.
Sharing media and context from merged PR #1889 for verification:
Deleting a virtual environment folder outside VS Code (for example rm -rf .venv) now refreshes the venv manager, so the deleted interpreter is no longer selected. Previously the status bar kept showing it until reload.
registerSystemPythonFeatures: a second watcher listens for deletions only (**/*). VS Code reports a deleted folder as the folder alone, so the existing **/activate watcher never fires for it.
VenvManager.hasEnvironmentAt: the delete handler triggers the existing debounced refresh only when the deleted path is, or contains, a known venv; other deletions are ignored. The check is one set lookup (about 2.6 µs per deletion whatever the number of venvs), so bulk deletions such as clearing __pycache__ stay cheap.
Not changed: venvs outside the workspace folders are not watched, as before.
Before / after
Folder with .venv (Python 3.13.15); .venv deleted from outside VS Code.
Activity
vs-code-engineering commentedon Oct 6, 2026
Sharing media and context from merged PR #1889 for verification:
Deleting a virtual environment folder outside VS Code (for example
rm -rf .venv) now refreshes the venv manager, so the deleted interpreter is no longer selected. Previously the status bar kept showing it until reload.registerSystemPythonFeatures: a second watcher listens for deletions only (**/*). VS Code reports a deleted folder as the folder alone, so the existing**/activatewatcher never fires for it.VenvManager.hasEnvironmentAt: the delete handler triggers the existing debounced refresh only when the deleted path is, or contains, a known venv; other deletions are ignored. The check is one set lookup (about 2.6 µs per deletion whatever the number of venvs), so bulk deletions such as clearing__pycache__stay cheap.Before / after
Folder with
.venv(Python 3.13.15);.venvdeleted from outside VS Code.Before
After
Validation
main@ 52f6ace.venvafter 30 snpm run lint,npm run compile-tests,npm run unittestmain.unit.test.ts)Created by Copilot
Source PR: #1889
fix: refresh venvs when a venv folder is deleted outside VS Code (Fixes