venv overwrites existing .gitignore
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 77.2k
- Forks
- 36k
- Métriques de merge des PR
- Métriques de PR en attente
Description
Bug report
Bug description
I cloned a github project with an existing .gitignore file.
I created a new python venv inside the cloned project using python3 -m venv .venv .
After creating the new venv, I see that the .gitignore file has been modified.
diff --git a/.gitignore b/.gitignore
index d0258704..f514b74c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,17 +1,2 @@
-.dev
-.idea/
-.hypothesis/
-__pycache__/
-db.sqlite3
-*.sw*
-*.pyc
-venv/
-.venv/
-environment_settings.py
-elm-stuff/
-.coverage
-media
-docker/.env
-node_modules
-package-lock.json
-.sass-cache
+# Created by venv; see https://docs.python.org/3/library/venv.html
+*
I found this documentation on the mentioned url added to the .gitignore file:
Changed in version 3.13: venv now creates a .gitignore file for Git by default.
Environment
- Arch linux 6.14.9
- Python 3.13.3
Expected behaviour
I would expect it to not overwrite an existing .gitignore file, so it only creates it if it isnt present already.
Update
Using
python3 -m venv .venvworks as expected, but I didpython3 -m venv .venv .(trailing dot) which creates a folder with a new venv named.venv, but also creates a venv inside the existing folder., and that's when it overwrites the.gitignore
Please let me know if I'm missing some details or you need further testing for triage the issue.
CPython versions tested on:
3.13
Operating systems tested on:
Linux
Linked PRs
- gh-139130
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Reproduisez le comportement avec python3 -m venv .venv . dans un projet qui contient déjà un .gitignore, puis comparez-le avec python3 -m venv .venv. Suivez le point d’entrée de python3 -m venv et vérifiez que la création de l’environnement ne remplace pas un .gitignore existant ; confirmez le comportement avec Python 3.13.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- tooling
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 35/100