dotenv run --no-override expands variables with the wrong precedence
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 35/100
Direzione di ricerca
Inizia dal percorso CLI run descritto nell’issue, in cui dotenv_values() espande le variabili prima che le chiavi dell’ambiente vengano filtrate. Esegui la riproduzione fornita e verifica che DOTENV_TEST_BASE e DOTENV_TEST_DERIVED utilizzino entrambi il valore dell’ambiente esistente, anche quando è vuoto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
With dotenv run --no-override, a variable can keep its value from the environment while another variable referring to it gets the value from .env. This leaves the child process with inconsistent configuration.
Steps to reproduce
With python-dotenv[cli] installed, run:
import os
import subprocess
import sys
import tempfile
from pathlib import Path
with tempfile.TemporaryDirectory() as directory:
path = Path(directory) / ".env"
path.write_text(
"DOTENV_TEST_BASE=file\n"
"DOTENV_TEST_DERIVED=${DOTENV_TEST_BASE}/suffix\n"
)
env = dict(os.environ)
env["DOTENV_TEST_BASE"] = "environment"
env.pop("DOTENV_TEST_DERIVED", None)
subprocess.run(
[
sys.executable, "-m", "dotenv", "-f", str(path),
"run", "--no-override", sys.executable, "-c",
"import os; print(os.environ['DOTENV_TEST_BASE']); "
"print(os.environ['DOTENV_TEST_DERIVED'])",
],
env=env,
check=True,
)
Expected behavior
Both values should use the existing environment variable, as they do with load_dotenv(override=False):
environment
environment/suffix
Actual behavior
environment
file/suffix
An existing empty string also reproduces this: the derived value is file/suffix instead of /suffix.
Environment
Reproduced on Windows with Python 3.13.15 and python-dotenv 1.2.3, from commit a00cb2eed0704cd6d2071b2004c37e95ccc86ee5.
Additional context
This is similar to #282, but affects the CLI. run calls dotenv_values(), which expands variables with override=True, before filtering out keys already in the environment. The fix is in #698.
Prepared with OpenAI Codex assistance.
- Lingua principale
- Python
- Stelle
- 8.9k
- Fork
- 581
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di theskumar/python-dotenv
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
theskumar/python-dotenv#699 · 1 commento ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 28/100
theskumar/python-dotenv#693 · 1 commento ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
theskumar/python-dotenv#683 · 4 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
theskumar/python-dotenv#644 · 2 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
theskumar/python-dotenv#631 · 3 commenti · 1 reazione ·
Tutte le issue di theskumar/python-dotenv
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
zostera/django-bootstrap4#894 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
use-agent-os/agent-os#3276 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
NousResearch/hermes-agent#117848 ·