diff --git a/pipenv/cli.py b/pipenv/cli.py index 57c3cbf8..2e676c24 100644 --- a/pipenv/cli.py +++ b/pipenv/cli.py @@ -40,7 +40,7 @@ from .environments import ( PIPENV_COLORBLIND, PIPENV_NOSPIN, PIPENV_SHELL_COMPAT, PIPENV_VENV_IN_PROJECT, PIPENV_USE_SYSTEM, PIPENV_TIMEOUT, PIPENV_SKIP_VALIDATION, PIPENV_HIDE_EMOJIS, PIPENV_INSTALL_TIMEOUT, - PYENV_INSTALLED, PIPENV_YES + PYENV_INSTALLED, PIPENV_YES, PIPENV_DONT_LOAD_ENV ) # Backport required for earlier versions of Python. @@ -114,10 +114,11 @@ project = Project() def load_dot_env(): - denv = dotenv.find_dotenv(os.sep.join([project.project_directory, '.env'])) - if os.path.isfile(denv): - click.echo(crayons.white('Loading .env environment variables…', bold=True), err=True) - dotenv.load_dotenv(denv, override=True) + if not PIPENV_DONT_LOAD_ENV: + denv = dotenv.find_dotenv(os.sep.join([project.project_directory, '.env'])) + if os.path.isfile(denv): + click.echo(crayons.white('Loading .env environment variables…', bold=True), err=True) + dotenv.load_dotenv(denv, override=True) def add_to_path(p): diff --git a/pipenv/environments.py b/pipenv/environments.py index 52c66e41..7bae7b3c 100644 --- a/pipenv/environments.py +++ b/pipenv/environments.py @@ -24,6 +24,9 @@ PIPENV_PIPFILE = os.environ.get('PIPENV_PIPFILE') # Tells pipenv to not try to install -e dependencies to get their dependency information. PIPENV_DONT_EAT_EDITABLES = bool(os.environ.get('PIPENV_DONT_EAT_EDITABLES')) +# Tells pipenv to not load .env files. +PIPENV_DONT_LOAD_ENV = bool(os.environ.get('PIPENV_DONT_LOAD_ENV')) + # Tell Pipenv to default to yes at all prompts. PIPENV_YES = bool(os.environ.get('PIPENV_YES'))