(GitKraken) Pre-commit Failed Exit Code: 1
Asked Answered
F

4

8

I'm using GitKraken (not sure if relevant) and as I'm trying to commit, I get this error message: enter image description here

And as I press the button "View Hook Output" I get the following:

pre-commit

husky > npm run -s precommit (node v8.9.4)[?25l

npm > Running tasks for src/**/*.js

\ yarn format git add (...lots of these two rows...)
\ yarn format git add

"yarn format" found some errors. Please fix them and try committing again. yarn run v1.6.0 $ prettier-standard './src/**/*.js' C:\mypath\myfile.js info[Visit [0;1mhttps://yarnpkg.com/en/docs/cli/run for documentation about this comand.

prettier-eslint [ERROR] eslint fix failed due to an eslint error prettier-standard [ERROR] There was an error formatting "C:\mypath\messages.js": TypeError: Cannot read property 'range' of null

at SourceCode.getTokenBefore (c:\mypath\index.js:303:18)
at checkSpacingBefore (C:\mypath\template-curly-spacing.js:52:42)
at TemplateElement (C:\mypath\template-curly-spacing.js:117:17)
at listeners.(anonymous function).forEach.listener (C:\mypath\safe-emitter.js:47:58)
at Array.forEach (<anonymous>)
at Object.emit (C:\mypath\safe-emitter.js:47:38)
at NodeEventGenerator.applySelector (C:\mypath\node_modules\eslint\lib\utilode-event-generator.js:251:26)
at NodeEventGenerator.applySelectors (C:\mypath\node_modules\eslint\lib\util\node-event-generator.js:280:22)
at NodeEventGenerator.enterNode (C:\mypath\node-event-generator.js:294:14)
at CodePathAnalyzer.enterNode (C:\mypath\code-path-analyzer.js:608:23)
at Traverser.enter [as _enter] (C:\mypath\node_modules\eslint\lib\linter.js:865:28)
at Traverser._traverse (C:\mypath\traverser.js:132:14)
at Traverser._traverse (C:\mypath\node_modules\eslint\lib\util\traverser.js:144:34)
at Traverser._traverse (C:\mypath\node_modules\eslint\lib\util\traverser.js:147:30)
at Traverser._traverse (C:\mypath\traverser.js:144:34)
at Traverser._traverse (C:\mypath\traverser.js:147:30)

failure formatting 1 file with prettier-standard error Command failed with exit code 1.

husky > pre-commit hook failed (add --no-verify to bypass) exit

What is causing this? No one can commit anything on GitKraken or Sourcetree. Only on command line. Very strange. What might be the cause and solution to this? I've heard some comments about npm versions used by husky or yarn.

Foretopmast answered 14/5, 2018 at 14:36 Comment(1)
You are able to commit via command line? Is there a file named pre-commit in the repositorys .git/hooks folder? Can you post its contents?Delp
S
4

From GitKraken:

Some advanced hooks may rely on features not included in GitKraken's bundled minimal Git install. You can select a full Git install for GitKraken to use from Preferences > Experimental > Git Executable after downloading and installing Git from https://git-scm.com/download/win.

Sorgo answered 16/8, 2023 at 10:7 Comment(1)
This actually fixed my git hook that ran a command using husky+npx. I had no clue as to why it was failing only in GitKraken but not from CLI or VS Code but this explains itSedillo
S
2

I was having the same issue but managed to temporarily fix it by removing the precommit npm module, be mind full this is not the ideal way as precommit runs the test scripts before the code is pushed to your repository.

use below command to remove recommit. npm remove precommit

Sealy answered 2/6, 2018 at 9:19 Comment(0)
R
0

I recently just solved this on a nodejs project i forked from by removing anything precommit was.

  • .Git/hooks/
  • package.json
  • node_modules

Using visual studio you need to be in solution explorer and show all files otherwise they will be hidden.

Representational answered 17/5, 2020 at 23:20 Comment(0)
L
0

If using husky to execute hooks in a node-based project on Windows, this issue may be relevant:

Husky: Issue with path resolution on Windows (#1397)

Check the version of husky you currently have installed in your project:

npm ls jusky

If the version is prior to v9.1.0, then update the package:

npm update husky

Then re-install your git hooks:

npx husky install

Leoleod answered 11/8 at 6:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.