theskumar / theskumar/python-dotenv
load_dotenv does not work with variables in values
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 8.9k
- Fork
- 581
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
I have a .env file with this variables similar to those explained in the library README:
# Development settings
DOMAIN=example.org
ADMIN_EMAIL=admin@${DOMAIN}
ROOT_URL=${DOMAIN}/app
# base work directory
WORKDIR=/workdir_shared
# logdir
LOGDIR=${WORKDIR}/logs
When I run this script I see that the values of variables ${DOMAIN} and ${WORKDIR} are not applied. I get:
DOMAIN: example.org
ROOT_URL: ${DOMAIN}/app
ADMIN_EMAIL: admin@${DOMAIN}
WORKDIR: /workdir_shared
LOGDIR: ${WORKDIR}/logs
Whe it should be:
DOMAIN: example.org
ROOT_URL: example.org/app
ADMIN_EMAIL: admin@example.org
WORKDIR: /workdir_shared
LOGDIR: workdir_shared/logs
What can be wrong?
This is the script code:
import os
from dotenv import load_dotenv
load_dotenv(verbose=True, interpolate=True)
print("DOMAIN:", os.getenv("DOMAIN"))
print("ROOT_URL:", os.getenv("ROOT_URL"))
print("ADMIN_EMAIL:", os.getenv("ADMIN_EMAIL"))
print("WORKDIR:", os.getenv("WORKDIR"))
print("LOGDIR:", os.getenv("LOGDIR"))
I tried with "load_dotenv()" with same result.
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.
Direzione di ricerca
Start by reproducing the issue with the provided .env contents and Python script, then trace load_dotenv's interpolation path. Check how referenced variables are resolved and add coverage for DOMAIN and WORKDIR substitutions; done means the shown ROOT_URL, ADMIN_EMAIL, and LOGDIR values expand as expected.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- devops
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Attiva
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 65/100