Closed Bug 1229154 Opened 6 years ago Closed 5 years ago
`mach eslint` fails on Windows with Windows
Error: Error 193 %1 is not a valid Win32 application
jared@jaws-win8 /c/fx $ mach eslint browser/base/content/ 0:00.92 Running c:\Users\jared\AppData\Roaming\npm\eslint in browser/base/content/ 0:00.92 c:\Users\jared\AppData\Roaming\npm\eslint --ext [.js,.jsm,.jsx] browser/base/content/ Error running mach: ['eslint', 'browser/base/content/'] The error occurred in code that was called by the mach command. This is either a bug in the called code itself or in the way that mach is calling it. You should consider filing a bug for this issue. If filing a bug, please include the full output of mach, including this error message. The details of the failure are as follows: WindowsError: [Error 193] %1 is not a valid Win32 application File "c:\fx\python/mach_commands.py", line 220, in eslint ensure_exit_code=False, # Don't throw on non-zero exit code. File "c:\fx\python/mach\mach\mixin\process.py", line 121, in run_process proc = subprocess.Popen(args, cwd=cwd, env=use_env) File "c:\mozilla-build\python\lib\subprocess.py", line 710, in __init__ errread, errwrite) File "c:\mozilla-build\python\lib\subprocess.py", line 958, in _execute_child startupinfo)
On both Windows and UNIX, you can execute a binary executable and it works. That's normal. On UNIXen, if an executable file isn't an ELF/binary, the first line of the file is examined for the shebang (#!<binary>). If that's present, the executable referenced is run and the file is passed to it. Windows doesn't have exactly this behavior. So, if you try to launch a process from a file with a shebang, you get the "is not a valid Win32 application" error. If you are inside a msys shell, the shell itself looks for the shebang and you are good. But Python processes aren't spawned directly from the shell: they are spawned from Python using the Win32 APIs directly. So to execute a process via the Python APIs, it needs to be a true Win32 executable or it needs to be spawned through a shell. If you pass require_unix_environment=True to mach's run_process() helper function, it will spawn processes in an appropriate shell and the shebang detection should work. Otherwise, the argument passed must be a Win32 executable on Windows.
Wow, very insightful. Thanks for the details, I'll put a patch up here shortly.
Assignee: nobody → jaws
Status: NEW → ASSIGNED
Tested this change and it now works through mach on Windows. Thanks!
Attachment #8694327 - Flags: review?(gps)
https://hg.mozilla.org/integration/fx-team/rev/c99b324d74a4064338e509a751b80c1aedb2a8b2 Bug 1229154 - Launch 'eslint' with UNIX environment since 'eslint' is not a valid Win32 binary. r=gps
You need to log in before you can comment on or make changes to this bug.