Carriage Return Characters in manage.py
Closed this issue · 4 comments
When attempting to create a superuser with the command docker-compose exec api ./manage.py createsuperuser
, on Windows, I received the error /usr/bin/env: ‘python\r’: No such file or directory
.
Searching this error, I found this page. As suggested, removing the carriage return characters (\r) from manage.py fixed this issue.
It may be that this is a Windows specific issue. Worth looking into?
Yes, looks like a Windows issue. I don't see carriage return ('\r') characters in manage.py on a Linux system:
00000000 23 21 2f 75 73 72 2f 62 69 6e 2f 65 6e 76 20 70 |#!/usr/bin/env p|
00000010 79 74 68 6f 6e 0a 22 22 22 44 6a 61 6e 67 6f 27 |ython."""Django'|
Only 0a ('\n'), not 0d ('\r').
Does the file have '\r' characters on your Windows system? If yes, then there may be a git-config(1) setting that has been configured to add carriage return. Maybe core.eol
or core.autocrlf
(documentation here: https://git-scm.com/docs/git-config).
The reason why carriage returns shouldn't be added on Windows is because these Python source files are built into Linux container images and executed by Python on Linux. They don't expect Windows line endings.
Interesting, yes, there were \r characters in my file. I'll do some investigation - sounds like it's likely an issue on my end in which case!
Fixed, on windows, autocrlf = false
must be added to your gitconfig
Thanks, I updated the setup instructions based on what you found!