manage.py is asking env. but it's not exist
Categories
(Webtools Graveyard :: Pontoon, defect, P2)
Tracking
(Not tracked)
People
(Reporter: bjh13579, Assigned: mozilla)
Details
Attachments
(2 files)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:86.0) Gecko/20100101 Firefox/86.0
Steps to reproduce:
- some git merge - dependency bot + etc (please refer attatching files)
- typing heroku run -a translates ./manage.py sync_projects
Actual results:
$ heroku run -a translates ./manage.py sync_projects
Running ./manage.py sync_projects on ⬢ translates... up, run.5956 (Standard-1X)
./manage.py:14: UserWarning: Not reading ./.env - it doesn't exist.
dotenv.read_dotenv(os.environ.get("DOTENV_PATH"))
/app/pontoon/base/celeryapp.py:20: UserWarning: Not reading /app/.env - it doesn't exist.
Expected results:
i think error is not occur, so it's some confused. but it's command (sync_projects) is working.
Comment 1•4 years ago
|
||
Fabien, this seems like a regression from https://github.com/mozilla/pontoon/commit/f245ebff853422453a3e00d7a6f0d74c70812241.
Could you please have a look?
Assignee | ||
Comment 2•4 years ago
|
||
I think it is not related.
When DOTENV_PATH
is not defined, os.environ.get()
returns None
, which is the default value expected by the dotenv.read_dotenv()
function:
Additionally, the following warning
./manage.py:14: UserWarning: Not reading ./.env - it doesn't exist.
Should not be displayed if I understand correctly the following line of the manage.py
file:
I also made tests to be sure and here are the results:
With no .env
file and no DOTENV_PATH
:
$ python manage.py sync_projects
...
KeyError: 'SECRET_KEY'
With .env
file and no DOTENV_PATH
:
$ python manage.py sync_projects
...
[INFO:pontoon.sync.models] 2021-03-18 16:12:25,353 Sync complete.
With no .env
and DOTENV_PATH=pontoon.env
(pontoon.env
exists):
$ python manage.py sync_projects
...
[INFO:pontoon.sync.models] 2021-03-18 16:14:15,568 Sync complete.
With no .env
and DOTENV_PATH=foobar
:
$ python manage.py sync_projects
...
KeyError: 'SECRET_KEY'
Assignee | ||
Comment 3•4 years ago
|
||
Hum,
I said that the warning should not be displayed... but it is for me too when there is no .env
or a wrong path in DOTENV_PATH
:
manage.py:14: UserWarning: Not reading foobar - it doesn't exist.
So the manage.py:11
line is probably not working...
Assignee | ||
Comment 4•4 years ago
|
||
I read the issue to fast... I thought there where an error caused by dotenv but the issue is about the warning itself (I understood when I saw the attached screenshot)... Sorry for the spam...
So, I get back to commit 72f172a9b654e8ed4d4570df3963443ef743ddfb
(the one before my PR) and the warning is not displayed.. The upgrade from django-dotenv
1.3.0 to 1.4.2 is the cause of the issue.
It seems they added stacklevel=2
to the warnings.warn()
call, so
warnings.filterwarnings('ignore', module='dotenv')
Should now be replaced by
warnings.filterwarnings('ignore', module='__main__')
to remove the warning... But this could hide other warning too...
Maybe we should call the dotenv.read_dotenv()
function only if the DOTENV_PATH
variable or the .env
file exist?
Sorry again for all the spam ^^'
Reporter | ||
Comment 5•4 years ago
|
||
No Problem, I just solve issue :) and thanks a lot!
Comment 6•4 years ago
|
||
Updated•4 years ago
|
Updated•4 years ago
|
Description
•