Opened 8 years ago

Closed 7 years ago

Last modified 7 years ago

#28174 closed Bug (fixed)

Cannot run `manage.py runserver` on Windows with quotation mark in .env file (TypeError: environment can only contain strings)

Reported by: Paul Mestemaker Owned by: Mark Rogaski
Component: Core (Management commands) Version: 1.11
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

We have a .env file with a SECRET_KEY defined as follows
SECRET_KEY="SECRETKEYHERE"

This causes a failure with Django 1.11. The workarounds are:
1) Downgrade to Django 1.10
2) Remove the quotation marks and just have SECRET_KEY=SECRETKEYHERE

This appears to only be a problem on Windows and does not repro on Mac/Linux.

(tmadashboard) c:\development\workspaces\tma\dashboard\dashboard>pip install django==1.10 --upgrade
Collecting django==1.10
  Downloading Django-1.10-py2.py3-none-any.whl (6.8MB)
    100% |################################| 6.8MB 124kB/s
Installing collected packages: django
  Found existing installation: Django 1.11
    Uninstalling Django-1.11:
      Successfully uninstalled Django-1.11
Successfully installed django-1.10
 
(tmadashboard) c:\development\workspaces\tma\dashboard\dashboard>python manage.py runserver
Performing system checks...
 
RUNNING IN DEVELOPMENT MODE. ADDING STATIC FILE DIRECTORIES TO SERVE
System check identified no issues (0 silenced).
May 04, 2017 - 12:46:16
Django version 1.10, using settings 'dashboard.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
 
(tmadashboard) c:\development\workspaces\tma\dashboard\dashboard>pip install --upgrade django
Collecting django
  Using cached Django-1.11-py2.py3-none-any.whl
Requirement already up-to-date: pytz in c:\development\python\python2712\virtualenvs\tmadashboard\lib\site-packages (from django)
Installing collected packages: django
  Found existing installation: Django 1.10
    Uninstalling Django-1.10:
      Successfully uninstalled Django-1.10
Successfully installed django-1.11
 
(tmadashboard) c:\development\workspaces\tma\dashboard\dashboard>python manage.py runserver
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "c:\development\python\Python2712\virtualenvs\tmadashboard\lib\site-packages\django\core\management\__init__.py", line 363, in execute_from_command_line
    utility.execute()
  File "c:\development\python\Python2712\virtualenvs\tmadashboard\lib\site-packages\django\core\management\__init__.py", line 355, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "c:\development\python\Python2712\virtualenvs\tmadashboard\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "c:\development\python\Python2712\virtualenvs\tmadashboard\lib\site-packages\django\core\management\commands\runserver.py", line 62, in execute
    super(Command, self).execute(*args, **options)
  File "c:\development\python\Python2712\virtualenvs\tmadashboard\lib\site-packages\django\core\management\base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "c:\development\python\Python2712\virtualenvs\tmadashboard\lib\site-packages\django\core\management\commands\runserver.py", line 101, in handle
    self.run(**options)
  File "c:\development\python\Python2712\virtualenvs\tmadashboard\lib\site-packages\django\core\management\commands\runserver.py", line 110, in run
    autoreload.main(self.inner_run, None, options)
  File "c:\development\python\Python2712\virtualenvs\tmadashboard\lib\site-packages\django\utils\autoreload.py", line 332, in main
    reloader(wrapped_main_func, args, kwargs)
  File "c:\development\python\Python2712\virtualenvs\tmadashboard\lib\site-packages\django\utils\autoreload.py", line 303, in python_reloader
    exit_code = restart_with_reloader()
  File "c:\development\python\Python2712\virtualenvs\tmadashboard\lib\site-packages\django\utils\autoreload.py", line 289, in restart_with_reloader
    exit_code = subprocess.call(args, env=new_environ)
  File "c:\development\python\python2712\Lib\subprocess.py", line 523, in call
    return Popen(*popenargs, **kwargs).wait()
  File "c:\development\python\python2712\Lib\subprocess.py", line 711, in __init__
    errread, errwrite)
  File "c:\development\python\python2712\Lib\subprocess.py", line 959, in _execute_child
    startupinfo)
TypeError: environment can only contain strings

Change History (11)

comment:1 by Tim Graham, 8 years ago

Could you please bisect to determine the Django commit where the behavior changed? Please also provide steps to reproduce the issue and explain why Django is at fault.

comment:2 by Tim Graham, 8 years ago

Resolution: needsinfo
Status: newclosed

comment:3 by Mark Rogaski, 7 years ago

Resolution: needsinfo
Status: closednew

comment:4 by Mark Rogaski, 7 years ago

Owner: changed from nobody to Mark Rogaski
Status: newassigned

comment:5 by Mark Rogaski, 7 years ago

Version 0, edited 7 years ago by Mark Rogaski (next)

comment:7 by Mark Rogaski, 7 years ago

Triage Stage: UnreviewedAccepted

comment:8 by Tim Graham, 7 years ago

Has patch: set
Patch needs improvement: set
Severity: NormalRelease blocker

comment:9 by Tim Graham <timograham@…>, 7 years ago

Resolution: fixed
Status: assignedclosed

In fc6b90b:

[1.11.x] Fixed #28174 -- Fixed crash in runserver's autoreload with Python 2 on Windows with non-str environment variables.

comment:10 by Tim Graham <timograham@…>, 7 years ago

In 37b2602c:

Refs #28174 -- Added 1.11.4 release note for Python 2 runserver autoreload fix.

Forwardport of fc6b90bdb7a9531e988245942f79518308616b7b from stable/1.11.x

comment:11 by Tim Graham <timograham@…>, 7 years ago

In d9ef8ff:

[1.11.x] Refs #28174 -- Fixed autoreload test crash on Python 2/non-ASCII path.

Note: See TracTickets for help on using tickets.
Back to Top