🐛 fix(create): prevent venv from racing virtualenv on gitignore creation#3092
Merged
gaborbernat merged 3 commits intopypa:mainfrom Mar 9, 2026
Merged
🐛 fix(create): prevent venv from racing virtualenv on gitignore creation#3092gaborbernat merged 3 commits intopypa:mainfrom
gaborbernat merged 3 commits intopypa:mainfrom
Conversation
Pass --without-scm-ignore-files to subprocess venv on 3.13+ so virtualenv always controls .gitignore creation. Previously the subprocess path let venv create .gitignore (3.13+ default) while the inline path did not, causing non-deterministic test results. Fixes pypa#3089
rahuldevikar
approved these changes
Mar 9, 2026
Contributor
rahuldevikar
left a comment
There was a problem hiding this comment.
Interesting find. Thanks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Python 3.13 changed
python -m venvto create a.gitignorefile by default, but theEnvBuilder()API kept the old default of not creating one. This means virtualenv's venv creator produces different.gitignorecontent depending on whether it takes the inline path (EnvBuilder) or the subprocess path (python -m venv), which path is taken depends on runtime conditions — leading to a 50:50 flaky failure intest_create_no_seedon Fedora and similar environments. 🎲The fix passes
--without-scm-ignore-filesto the subprocess invocation on Python 3.13+, ensuring virtualenv always controls.gitignorecreation through its ownsetup_ignore_vcs()regardless of code path. This also fixes a secondary issue where--no-vcs-ignorewas silently ignored in the subprocess path on 3.13+, since venv would create the file before virtualenv could decide not to.Fixes #3089