Skip to content

fix: skip package refresh for deleted environments - #1833

Merged
Eleanor Boyd (eleanorjboyd) merged 1 commit into
microsoft:mainfrom
eleanorjboyd:agents/fix-package-refresh-deleted-env
Sep 30, 2026
Merged

Eleanor Boyd (eleanorjboyd) merged 1 commit into
microsoft:mainfrom
eleanorjboyd:agents/fix-package-refresh-deleted-env

Conversation

@eleanorjboyd

@eleanorjboyd Eleanor Boyd (eleanorjboyd) commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1824

Problem

Deleting and recreating a virtual environment (for example make clean-venv followed by make venv) surfaced an "Error refreshing packages" notification.

Explanation

The package watcher observes site-packages. Deleting the environment fires delete events, which schedule a debounced refresh. That refresh then ran pip list against the interpreter that had just been removed, so the failure was an expected consequence of the deletion rather than an actionable problem — but it was reported to the user as an error.

Fix

watchPackageChangesForEnvironment now verifies the environment executable exists before refreshing.

  • If the executable is missing, the refresh is not attempted
  • Because a deletion is usually followed by a recreation, the watcher retries on the existing 500ms debounce interval for up to 30 seconds
  • If the executable never returns, the watcher stops retrying and logs at debug level.
  • Genuine stat failures and genuine refresh failures are still logged as errors.

Deleting and recreating a virtual environment triggered the package
watcher, which ran `pip list` against the already-removed interpreter and
surfaced an "Error refreshing packages" notification. The failure was an
expected consequence of the deletion, not an actionable problem.

The watcher now verifies the environment executable exists before
refreshing. While the executable is missing it retries on the existing
debounce interval for up to 30 seconds, so package state is still
refreshed once the recreated environment appears. Genuine stat and
refresh failures continue to be logged.

Also teaches `isFileNotFoundError` to recognize VS Code `FileSystemError`
missing-entry codes in addition to Node's `ENOENT`.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@eleanorjboyd Eleanor Boyd (eleanorjboyd) added the bug Issue identified by VS Code Team member as probable bug label Sep 28, 2026
@eleanorjboyd
Eleanor Boyd (eleanorjboyd) marked this pull request as draft September 28, 2026 20:39
@eleanorjboyd
Eleanor Boyd (eleanorjboyd) marked this pull request as ready for review September 30, 2026 16:09
@eleanorjboyd
Eleanor Boyd (eleanorjboyd) merged commit c8bb80b into microsoft:main Sep 30, 2026
45 of 46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue identified by VS Code Team member as probable bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Get a "Error refreshing packages" toast when in the middle of recreating a virtual environment

4 participants