theskumar / theskumar/python-dotenv
load_dotenv does not work with variables in values
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 8.9k
- Forks
- 581
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
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.
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
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- devops
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- Active
- Clarté
- Plutôt claire
- Accessibilité débutants
- 65/100