TonyYen
TonyYen

Reputation: 51

Cannot execute binary file: Exec format error (code 126)

Here are the error messages when I commit:

.husky/../npmw: line 30: .husky/../target/node/node: cannot execute binary file: Exec format error Using node installed locally .husky/../npmw: line 40: .husky/../target/node/node: cannot execute binary file: Exec format error Using npm installed locally .husky/../npmw: line 41: .husky/../target/node/node: cannot execute binary file: Exec format error husky - pre-commit hook exited with code 126 (error)

Not sure if it's related to .husky/precommit

content as below:

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"


"$(dirname "$0")/../npmw" exec --no-install lint-staged

Originally,I use git commit -m "xxx" --no-verify, but now I'm not allowed to due to my supervisor.

I've tried npm install.

Upvotes: 3

Views: 4533

Answers (3)

Hayate
Hayate

Reputation: 81

I have the same problem.
After hit

git commit -m "testing pre-commit code"

got error

.husky/pre-commit: .husky/pre-commit: cannot execute binary file husky

  • pre-commit script failed (code 126)

Resolved that after change pre-commit file encoding from UTF-16 (as it is as default after initializing husky) to UTF-8. I have done this in VS Code.

enter image description here enter image description here

It works! :))

Upvotes: 4

ADDPD
ADDPD

Reputation: 21

The modified file is encoded as UTF-8

Upvotes: 1

user20666798
user20666798

Reputation: 46

I guess this error appeared on Windows and husky version 5.x, and I also encountered the same problem, and then I deleted ./husky/commit-MSG files, and after manually re-creation, I can submit it normally.

Upvotes: 3

Related Questions