Skip to content

🐛 fix(create): prevent venv from racing virtualenv on gitignore creation#3092

Merged
gaborbernat merged 3 commits intopypa:mainfrom
gaborbernat:3089
Mar 9, 2026
Merged

🐛 fix(create): prevent venv from racing virtualenv on gitignore creation#3092
gaborbernat merged 3 commits intopypa:mainfrom
gaborbernat:3089

Conversation

@gaborbernat
Copy link
Contributor

@gaborbernat gaborbernat commented Mar 9, 2026

Python 3.13 changed python -m venv to create a .gitignore file by default, but the EnvBuilder() API kept the old default of not creating one. This means virtualenv's venv creator produces different .gitignore content 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 in test_create_no_seed on Fedora and similar environments. 🎲

The fix passes --without-scm-ignore-files to the subprocess invocation on Python 3.13+, ensuring virtualenv always controls .gitignore creation through its own setup_ignore_vcs() regardless of code path. This also fixes a secondary issue where --no-vcs-ignore was silently ignored in the subprocess path on 3.13+, since venv would create the file before virtualenv could decide not to.

Fixes #3089

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
@gaborbernat gaborbernat changed the title fix flaky venv gitignore test on Python 3.13+ 🐛 fix(create): prevent venv from racing virtualenv on gitignore creation Mar 9, 2026
Copy link
Contributor

@rahuldevikar rahuldevikar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting find. Thanks

@gaborbernat gaborbernat merged commit e1af35d into pypa:main Mar 9, 2026
113 of 115 checks passed
@gaborbernat gaborbernat deleted the 3089 branch March 9, 2026 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test_create_no_seed[*-venv-*] flaky gitignore check?

2 participants