-
-
Notifications
You must be signed in to change notification settings - Fork 16.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If using a .env file with Docker, the Flask CLI still tells you to install python-dotenv #3872
Comments
I was facing a similar issue when using "pipenv". "pipenv" automatically detects .env files and does not need "python-dotenv" package", but flask still wants you to install it.. |
If you're using another tool that loads dotenv files before The warning was added in #2668, and it helped me catch an incomplete setup more than a few times, so I think it should stay for now. |
Is there a case to be made to have it disabled / skipped by default? Especially since most deployment platforms allow you to insert environment variables through their CLI (such as Heroku). Combine that with other application runtime environments (systemd, Docker, Kubernetes, ECS, etc.) having their own mechanisms for loading environment variables without python-dotenv. It's nice that the skip env variable exists but the current implementation means you need to set it in every application you deploy. If it's the norm, shouldn't it be the default? This way in production it defaults to disabled because nearly everyone would be using Docker or systemd or some other hosted solution. Then in development you can choose to overwrite it as needed. |
Docker Compose and pipenv, while convenient tools, are not nearly the norm. Also, if you're deploying you should never be running the development server, at which point you'd never see this message anyway because only the |
Then I believe there's a bug in how the tip is being output because right now if you run any Personally I don't even use |
Ah, you're right, the cli in general checks for the file. I'm not going to remove the message right now, so your best bet is setting the extra environment variable. You could automate this if you use something like cookiecutter to create new projects from templates. |
Sure it can be automated in development, but it means setting it in every project and in production chances are you're not committing your That could be adding it through the Heroku CLI or editing whatever env variables / env file / secrets mechanism you use with Docker Compose, systemd, Kubernetes, ECS, Swarm, DigitalOcean Apps or the half dozen other application runtimes that all load env variables in various ways without needing Edit:
The only reason I'm pushing back on this is because it's an inconvenience to every person running Flask in production since the tip comes up every time you run any If it worked as you originally described by only being output with |
If you have a
.env
file and are using Docker you don't need to installpython-dotenv
.But every time you run any
flask
CLI command, Flask will output* Tip: There are .env or .flaskenv files present. Do "pip install python-dotenv" to use them.
to stdout before any other output.Perhaps this tip could be removed all together? IMO if you're using env files you likely already know to use
python-dotenv
and if you're using Docker you have access to your environment variables through other means.Expected Behavior
No tip output to be present.
Actual Behavior
It produces this:
Environment
The text was updated successfully, but these errors were encountered: