Skip to content

Error running check-clang-format precommit ENOENT (Windows) #59

Open
@alanwright

Description

@alanwright

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:

"scripts": {
    "precommit": "check-clang-format \"npm format\"",
    "format": "git-clang-format"
  },

cmd output (ran as admin):

> 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

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions