You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If foo.py is not executable, pre-commit run foo --all-files produces a reasonable error message:
foo......................................................................Failed
- hook id: foo
- exit code: 1
Executable `/[redacted]/foo.py` is not executable
However, if it is executable but doesn't not contain a shebang, you get
$ pre-commit run foo --all-files
foo......................................................................An unexpected error has occurred: OSError: [Errno 8] Exec format error: '/[redacted]/foo.py'
Check the log at /[redacted]/.cache/pre-commit/pre-commit.log
Log contents:
version information
pre-commit version: 2.1.1
sys.version:
3.7.6 (default, Dec 30 2019, 19:38:28)
[Clang 11.0.0 (clang-1100.0.33.16)]
sys.executable: /[redacted]/venv/bin/python3
os.name: posix
sys.platform: darwin
error information
An unexpected error has occurred: OSError: [Errno 8] Exec format error: '/[redacted]/foo.py'
Traceback (most recent call last):
File "/[redacted]/venv/lib/python3.7/site-packages/pre_commit/error_handler.py", line 54, in error_handler
yield
File "/[redacted]/venv/lib/python3.7/site-packages/pre_commit/main.py", line 371, in main
return run(args.config, store, args)
File "/[redacted]/venv/lib/python3.7/site-packages/pre_commit/commands/run.py", line 339, in run
return _run_hooks(config, hooks, args, environ)
File "/[redacted]/venv/lib/python3.7/site-packages/pre_commit/commands/run.py", line 249, in _run_hooks
verbose=args.verbose, use_color=args.color,
File "/[redacted]/venv/lib/python3.7/site-packages/pre_commit/commands/run.py", line 165, in _run_single_hook
retcode, out = language.run_hook(hook, filenames, use_color)
File "/[redacted]/venv/lib/python3.7/site-packages/pre_commit/languages/script.py", line 19, in run_hook
return helpers.run_xargs(hook, cmd, file_args, color=color)
File "/[redacted]/venv/lib/python3.7/site-packages/pre_commit/languages/helpers.py", line 109, in run_xargs
return xargs(cmd, file_args, **kwargs)
File "/[redacted]/venv/lib/python3.7/site-packages/pre_commit/xargs.py", line 153, in xargs
for proc_retcode, proc_out, _ in results:
File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/_base.py", line 598, in result_iterator
yield fs.pop().result()
File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/_base.py", line 428, in result
return self.__get_result()
File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
raise self._exception
File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/[redacted]/venv/lib/python3.7/site-packages/pre_commit/xargs.py", line 146, in run_cmd_partition
*run_cmd, retcode=None, stderr=subprocess.STDOUT, **kwargs,
File "/[redacted]/venv/lib/python3.7/site-packages/pre_commit/util.py", line 208, in cmd_output_p
proc = subprocess.Popen(cmd, **kwargs)
File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 800, in __init__
restore_signals, start_new_session)
File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1551, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/[redacted]/foo.py'
The text was updated successfully, but these errors were encountered:
Repro steps:
Create a script hook.
foo.py
can be empty.If foo.py is not executable,
pre-commit run foo --all-files
produces a reasonable error message:However, if it is executable but doesn't not contain a shebang, you get
Log contents:
version information
error information
The text was updated successfully, but these errors were encountered: