Error on superuser creation

When creating a superuser with:
~/.commcare-cloud/repo$ commcare-cloud monolith django-manage make_superuser myemail@mydomain.com

I received the following error:

ssh 10.0.0.4 -o UserKnownHostsFile=/home/ccc/environments/monolith/known_hosts 'sudo -u cchq bash -c "cd /home/cchq/www/monolith/current; python_env/bin/python manage.py make_superuser myemail@mydomain.com"'
Ubuntu 18.04.2 LTS
/home/cchq/www/monolith/releases/2019-07-04_19.32/python_env/local/lib/python2.7/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
  """)
2019-07-15 19:29:12,359 INFO Raven is not configured (logging is disabled). Please see the documentation for more information.
2019-07-15 19:29:13,130 INFO AXES: BEGIN LOG
Traceback (most recent call last):
  File "manage.py", line 207, in <module>
    execute_from_command_line(sys.argv)
  File "/home/cchq/www/monolith/releases/2019-07-04_19.32/python_env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/home/cchq/www/monolith/releases/2019-07-04_19.32/python_env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/cchq/www/monolith/releases/2019-07-04_19.32/python_env/local/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/cchq/www/monolith/releases/2019-07-04_19.32/python_env/local/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/home/cchq/www/monolith/releases/2019-07-04_19.32/corehq/apps/domain/management/commands/make_superuser.py", line 35, in handle
    print("✓ User {} exists".format(couch_user.username))
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2713' in position 0: ordinal not in range(128)

By editing the
/home/cchq/www/monolith/releases/2019-07-04_19.32/corehq/apps/domain/management/commands/make_superuser.py
file and removing the special characters (checkmarks etc.) on lines 35, 39, 50, 52, 55, 57, the script ran fine. I assume other scripts handle these special unicode characters differently? I haven't dug into it yet, but no doubt someone on the Dimagi team will understand the issue.

Hi Ed,

We'll work on a fix for that, but in the meantime, you can also log on to the machine and run the command directly. I believe this failure only occurs when run through commcare-cloud.

  • Ethan

Thanks Ethan, could you elaborate with a couple of steps or perhaps an online document? I'm new to the CommCare cloud environment.
Cheers!

Hi Ed

There are some basic instructions for running management commands here: https://dimagi.github.io/commcare-cloud/commcare-cloud/basics#run-django-management-commands-on-django-managed-machines

1 Like

Hi Ed,

The command to run once you're in the appropriate environment as described in Simon's link is:

$ ./manage.py make_superuser myemail@mydomain.com

A fix for that issue is now available in the latest version of the commcare-hq code, so you should also be able to run it via commcare-cloud after your next code deploy. Thanks for reporting the issue.

1 Like

Nice! Thanks for the quick response!
Ed