Skip to content
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

deprecate FLASK_ENV #4714

Closed
davidism opened this issue Jul 30, 2022 · 5 comments · Fixed by #4720
Closed

deprecate FLASK_ENV #4714

davidism opened this issue Jul 30, 2022 · 5 comments · Fixed by #4720
Assignees
Milestone

Comments

@davidism
Copy link
Member

Nothing in Flask ever ended up using FLASK_ENV/app.env specifically. It adds a layer of complexity to the already confusing ways that app.debug and app.testing can affect what happens internally. It's already possible to control debug mode, the debugger, and the reloader individually, there's no need for this extra switch.

Feedback from users on the Discord channel, and observation of questions on Stack Overflow, suggests this env var is a source of confusion or at least extra work.

FLASK_ENV=development is very verbose, and that isn't changing with the introduction of the --env development option. It's much shorter to use the --debug flag.

The original idea behind FLASK_ENV was that it would be used like NODE_ENV. Nothing ever came of it though. NODE_ENV as it's used with any frontend framework is a build-time flag, it has more meaning when it actually affects how JavaScript gets compiled, which is not something that maps to Python/Flask very well.

pallets/werkzeug#2480 will make the "don't use the dev server in production" warning always shown, instead of only in certain situations. With this there will be no current difference between FLASK_ENV=development and FLASK_DEBUG=1. It is also generally redundant given that the dev server should never be run in production, and FLASK_ENV is probably only given when running the dev server.

@davidism davidism added this to the 2.2.0 milestone Jul 30, 2022
@davidism davidism self-assigned this Jul 30, 2022
@GAEfan
Copy link

GAEfan commented Aug 2, 2022

I must be missing something.

flask run --with-threads --host 127.0.0.1 --port 5000 --debug

yields

Error: No such option: --debug (Possible options: --debugger, --no-debugger)

@davidism
Copy link
Member Author

davidism commented Aug 2, 2022

--debug is an argument to flask, not to run. In Click, order matters, you can't mix options from one command with another.

flask --app example --debug run --port 8000

@crono782
Copy link

crono782 commented Aug 6, 2022

Seems like setting the DEBUG config key no longer works after this change.

from flask import Flask

app = Flask(__name__)
app.config['DEBUG'] = True

@app.route('/')
def index():
  return 'hello world'

results in:
$ flask run
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.

@davidism
Copy link
Member Author

davidism commented Aug 6, 2022

Read the docs about the debug config. That is not related to this change.

@crono782
Copy link

crono782 commented Aug 6, 2022

Man, my bad. I tested same code on 2.13 and same result. For some reason I thought that was previously working. Disregard my gaff plz.

pylipp added a commit to boxwise/boxtribute that referenced this issue Aug 11, 2022
Deprecated in Flask 2.2, see pallets/flask#4714.
Also use --app CLI option instead of FLASK_APP for consistency
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants