Skip to content

CI: prevent virtualenv redirect from occupying .venv - #26167

Merged
Eleanor Boyd (eleanorjboyd) merged 3 commits into
microsoft:mainfrom
eleanorjboyd:agents/venv-ci-path-diagnostics
Sep 25, 2026
Merged

Eleanor Boyd (eleanorjboyd) merged 3 commits into
microsoft:mainfrom
eleanorjboyd:agents/venv-ci-path-diagnostics

Conversation

@eleanorjboyd

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

Copy link
Copy Markdown
Member

Why

The virtualenv 21.12.0 update introduced a PEP 832 .venv redirect: when a project has a pyproject.toml, creating .virtualenv can also write a .venv file pointing to it. Our CI workflow copies in a pyproject.toml, creates .virtualenv for virtualenv tests, then runs python -m venv .venv for separate stdlib venv tests. Once virtualenv started writing that file, the latter command could no longer create its .venv directory. The passing run installed virtualenv 21.11.1; the failing release-branch runs installed 21.12.1.

Change

Pass --no-venv-redirect when creating .virtualenv. This opts out of the newly added side effect while keeping the two existing test environments at their original paths: .virtualenv for virtualenv and .venv for stdlib venv. Stop immediately if stdlib venv creation fails rather than reporting the subsequent missing executable as the primary error.

Related to #26164. The release branch still needs this fix and a passing Build workflow before release.

The venv matrix failed on both Windows and Linux when .venv was already occupied. Give the venv test interpreter a distinct path and log .venv state around setup so the producer of the collision can be identified in the next CI run.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@eleanorjboyd Eleanor Boyd (eleanorjboyd) added the no-changelog No news entry required label Sep 24, 2026
virtualenv 21.12 writes a .venv redirect file next to .virtualenv when a pyproject.toml exists. Disable that redirect so the following stdlib venv step can create its intended .venv directory.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@eleanorjboyd Eleanor Boyd (eleanorjboyd) changed the title CI: diagnose and avoid venv setup path collision CI: prevent virtualenv redirect from occupying .venv Sep 24, 2026
Keep the virtualenv redirect opt-out and explicit venv creation failure check; the path logging is no longer needed now that the collision is confirmed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@eleanorjboyd
Eleanor Boyd (eleanorjboyd) marked this pull request as ready for review September 25, 2026 15:10
@eleanorjboyd
Eleanor Boyd (eleanorjboyd) merged commit 70f695e into microsoft:main Sep 25, 2026
49 checks passed
Eleanor Boyd (eleanorjboyd) added a commit that referenced this pull request Sep 28, 2026
## Why
Backport of
[#26167](#26167) for the
2026.6 release branch. [virtualenv
21.12](https://github.com/pypa/virtualenv/releases/tag/21.12.0) began
writing a `.venv` redirect file when creating `.virtualenv` in a project
with `pyproject.toml`. The following `python -m venv .venv` then cannot
create the separate stdlib venv directory, breaking the release branch's
Windows and Linux venv jobs.

## Change
Pass `--no-venv-redirect` when creating `.virtualenv` so the existing
`.virtualenv` and `.venv` tests continue to use their original, separate
paths. Exit immediately if stdlib venv creation fails.

## Windows unit-test investigation
The Windows `ts-unit` job also intermittently failed on the first Native
Python Finder refresh while the subsequent refresh succeeded. The
locator-output diagnostic reproduced the failure: Pet logged `Skipping
refresh state sync for stale generation 0 because current generation is
1` and returned no environments. The finder had launched a configure
request in its constructor without awaiting it, while its first refresh
launched another configure and could start before the first completed.
Pet suppresses environment notifications from stale configuration
generations. Remove the redundant constructor configure; the first
refresh already configures and awaits completion before sending the
refresh request. The existing non-empty assertion is unchanged and still
includes the locator log on failure.

The release branch's Build workflow must pass after this lands before
releasing.

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Eleanor Boyd (eleanorjboyd) pushed a commit that referenced this pull request Sep 29, 2026
…nv (#26170)

Cherry-pick of #26168 from `release/2026.6`.

## Why
Backport of
[#26167](#26167) for the
2026.6 release branch. [virtualenv
21.12](https://github.com/pypa/virtualenv/releases/tag/21.12.0) began
writing a `.venv` redirect file when creating `.virtualenv` in a project
with `pyproject.toml`. The following `python -m venv .venv` then cannot
create the separate stdlib venv directory, breaking the release branch's
Windows and Linux venv jobs.

## Change
Pass `--no-venv-redirect` when creating `.virtualenv` so the existing
`.virtualenv` and `.venv` tests continue to use their original, separate
paths. Exit immediately if stdlib venv creation fails.

## Windows unit-test investigation
The Windows `ts-unit` job also intermittently failed on the first Native
Python Finder refresh while the subsequent refresh succeeded. The
locator-output diagnostic reproduced the failure: Pet logged `Skipping
refresh state sync for stale generation 0 because current generation is
1` and returned no environments. The finder had launched a configure
request in its constructor without awaiting it, while its first refresh
launched another configure and could start before the first completed.
Pet suppresses environment notifications from stale configuration
generations. Remove the redundant constructor configure; the first
refresh already configures and awaits completion before sending the
refresh request. The existing non-empty assertion is unchanged and still
includes the locator log on failure.

The release branch's Build workflow must pass after this lands before
releasing.

---------

Co-authored-by: vs-code-engineering[bot] <vs-code-engineering[bot]@users.noreply.github.com>
Co-authored-by: Michael Lively <milively@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog No news entry required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants