Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: stat /dev/null/pre-push: not a directory 32.06  ELIFECYCLE  Command failed with exit code 1. #669

Open
xuelichao opened this issue Mar 6, 2024 · 9 comments
Labels
bug Something isn't working waiting for response We need more details or confirmation

Comments

@xuelichao
Copy link

xuelichao commented Mar 6, 2024

🔧 Summary

This error happens when execute 'lefthook install' command in a docker build command with a react UI project.(in CICD ENV)

However, we can not encounter the same error in local PC when manually build an image with docker command.

The command pre-push is located at .git/command not the location '/dev/null/pre-push'

It seems that the method to get the command(pre-push) location(dir) is not correct in some conditions.

Lefthook version 1.5.0/1.6.5

Steps to reproduce

docker build --no-cache --network=host --pull --build-arg GOPROXY= --build-arg VERSION= --build-arg GIT_COMMIT= -t -f ./Dockerfile.test .

Dockerfile.test:
RUN pnpm i

package.json:
"prepare": "lefthook install",

Expected results

The command 'RUN pnpm i ' should be executed successfully and image should be built successfullly.

Actual results

Error: stat /dev/null/pre-push: not a directory 32.06  ELIFECYCLE  Command failed with exit code 1.

Possible Solution

Logs / Screenshots

LEFTHOOK_VERBOSE=true git ...
@xuelichao xuelichao added the bug Something isn't working label Mar 6, 2024
@mrexox
Copy link
Member

mrexox commented Mar 6, 2024

Please, don't install lefthook in the CI environment. I think you should explicitly specify this in your prepare script. Something like this:

"prepare": "[ -z $CI ] && lefthook install"

And if you use lefthook npm package it already handles this out of the box. You don't need an explicit lefthook install in the prepare script.

@mrexox
Copy link
Member

mrexox commented Apr 9, 2024

Hey! Do you still have issues with lefthook auto install?

@mrexox mrexox added the waiting for response We need more details or confirmation label Apr 9, 2024
@ragrag
Copy link

ragrag commented Jul 28, 2024

@mrexox

having similar issues during local install

Error: could not replace the hook: stat /dev/null/pre-commit: not a directory

@mrexox
Copy link
Member

mrexox commented Jul 29, 2024

@ragrag what does git rev-parse --git-path hooks return in your case?

@ragrag
Copy link

ragrag commented Jul 29, 2024

@mrexox thank you, when i run this in the repo root i get /dev/null

@mrexox
Copy link
Member

mrexox commented Jul 29, 2024

Looks like you have the git hooks configured to /dev/null. Please restore using this command: git config core.hooksPath .git/hooks/

@ragrag
Copy link

ragrag commented Jul 29, 2024

@mrexox thank you for the help that did it!

@ragrag
Copy link

ragrag commented Jul 29, 2024

would it make sense for lefthook to automatically set this when its incorrectly /dev/null? i seem to have this on all new git repos by default, (forgive me i'm not so fluent in git)

@mrexox
Copy link
Member

mrexox commented Jul 30, 2024

@ragrag you probably have a global config ~/.gitconfig with hooksPath set to /dev/null 🤔 I am not sure about it, but by default git must have .git/hooks configured for hooksPath.

Sometimes people use different hooksPath in their repos, and lefthook must adapt to this, so changing it implicitly may confuse other users. I think that this is more of a git-related things that lefthook-related.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working waiting for response We need more details or confirmation
Projects
None yet
Development

No branches or pull requests

3 participants