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
I'm setting up clang-format with precommit hook in a repository on a windows machine and getting the below error emitted from the check-clang-format script. The file it's complaining about does exist (I see it's written in python), but windows complains with ENOENT error. Am I missing anything in my setup or is there a bug?
> git commit -m "test"
Warning: Setting pre-commit script in package.json > scripts will be deprecated
Please move it to husky.hooks in package.json, a .huskyrc file, or a husky.config.js file
Or run ./node_modules/.bin/husky-upgrade for automatic update
See https://github.com/typicode/husky for usage
husky > pre-commit (node v8.11.1)
Error running git-clang-format: { Error: spawnSync node_modules\clang-format\bin\git-clang-format ENOENT
at _errnoException (util.js:1022:11)
at spawnSync (child_process.js:579:20)
at main (node_modules\clang-format\bin\check-clang-format.js:63:18)
at Object.<anonymous> (node_modules\clang-format\bin\check-clang-format.js:82:22)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
code: 'ENOENT',
errno: 'ENOENT',
syscall: 'spawnSync node_modules\\clang-format\\bin\\git-clang-format',
path: 'node_modules\\clang-format\\bin\\git-clang-format',
spawnargs: [ '--diff' ] }
husky > pre-commit hook failed (add --no-verify to bypass
The text was updated successfully, but these errors were encountered:
alanwright
changed the title
Error running git-clang-format ENOENT (Windows)
Error running check-clang-format precommit ENOENT (Windows)
Dec 12, 2018
I ran into the same issue on my windows machine.
The only workaround I found is to replace the spawn module (used in path-to-your-project/node_modules/clang-format/bin/check-clang-format.js) with cross-spawn:
#!/usr/bin/env node
/**
* @fileoverview This script provides the glue to run git-clang-format as a pre-
* commit hook.
*
* It checks that your git configuration is correct, and wraps the
* git-clang-format program by simply exiting with non-zero exit code if any
* changes are not already formatted correctly.
*
* To install it, see the instructions in the README.md.
*/
const spawn = require('cross-spawn').spawn.sync;`
I'm setting up clang-format with precommit hook in a repository on a windows machine and getting the below error emitted from the check-clang-format script. The file it's complaining about does exist (I see it's written in python), but windows complains with ENOENT error. Am I missing anything in my setup or is there a bug?
package.json:
cmd output (ran as admin):
The text was updated successfully, but these errors were encountered: