question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Always load .env file

See original GitHub issue

I think it might be worth considering to always load the .env file. As far I can see it is only loaded when running pipenv shell.

An example use case for this would be to share the configuration of PIPENV_VENV_IN_PROJECT so that the venv is created in the local directory. See also steps to replicate.

Describe your environment
  1. OS Type: Windows 10
  2. Python version: $ python -V: Python 2.7.11
  3. Pipenv version: $ pipenv --version: pipenv, version 8.2.7
Steps to replicate

Run in powershell:

PS C:\tmp\pipenv> echo "PIPENV_VENV_IN_PROJECT 1" > .env
PS C:\tmp\pipenv> cat .env
PIPENV_VENV_IN_PROJECT 1
PS C:\tmp\pipenv> pipenv --two
Expected result

.env file is loaded, resulting in:

Virtualenv location: C:\tmp\pipenv\.venv
Actual result

.env file is not loaded, resulting in:

Virtualenv location: C:\Users\Karim\.virtualenvs\playground-pipenv-RDyG8wOS

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

9reactions
p-himikcommented, Jan 2, 2018

I think that making pipenv handle .env during pipenv install is a better solution than direnv because:

  • pipenv already loads .env, so all necessary plumbing is already there
  • direnv has to be installed and configured separately, wherever you want to use pipenv - all developers’ machines, Jenkins, TravisCI etc.

My personal motivation for having this functionality: I have a project that uses private PyPI that doesn’t have a shared URL - each developer has their own URL because of security concerns, so I can’t put that URL in Pipfile. As far as I can see, the next logical place would be to put it in .env, but it’s not that useful when it’s not used by pipenv install.

0reactions
brenesercommented, Apr 15, 2020

I have the the same problem as others, need to install a package from a private repository. Having pipenv install using .env would be very very useful.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to automatically load and unload .env file with variables
Is it possible to load an .env file when accessing the directory they are in and unload these variables when changing to another...
Read more >
Is there a way to automatically load environment variables ...
A good practice is to use dotenv . You can load your environment by placing your environment variables into a file named .env...
Read more >
Automatically Load Environment Variables in Flask
Learn how to use python dotenv to automatically load environment variables into your Flask projects.
Read more >
Using .env Files for Environment Variables in Python ...
load_dotenv () will first look for a .env file and if it finds one, it will load the environment variables from the file...
Read more >
Basic Features: Environment Variables - Next.js
Note: If you are using a /src folder, please note that Next.js will load the .env files only from the parent folder and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found