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

hook not compatible with global gem install on windows #298

Closed
ariccio opened this issue Jul 14, 2022 · 4 comments · Fixed by #316
Closed

hook not compatible with global gem install on windows #298

ariccio opened this issue Jul 14, 2022 · 4 comments · Fixed by #316
Labels
Windows Windows case
Milestone

Comments

@ariccio
Copy link
Contributor

ariccio commented Jul 14, 2022

I am seeing an issue as someone who installed lefthook globally as recommended if you follow the instructions blindly...

I can see in a procmon trace that the hook tries to execute lefthook through bundler, which results in a command line like C:\Ruby31-x64\bin\ruby.exe -x C:/Ruby31-x64/bin/bundle exec lefthook -h, but I have no such gem installed in the project. I can run lefthook manually with no problem, its in my PATH.

Very annoyingly, if I run git push, it gets to echo "Can't find lefthook in PATH", but my console just hangs, nothing happening until I break into it (which exits). I have no idea why that happens.

I have no Lefthook.exe, only a lefthook.bat at "C:\Ruby31-x64\bin\lefthook.bat", so that's why it skips the first line.

I presume the easiest fix for me will be to add lefthook in my bundle. Someone else will surely hit this.

@ariccio
Copy link
Contributor Author

ariccio commented Jul 14, 2022

Related: #212

ariccio added a commit to ariccio/COVID-CO2-tracker that referenced this issue Jul 14, 2022
@Envek
Copy link
Member

Envek commented Jul 28, 2022

Hmm, I'm not even sure where lefthook.bat came from. Did RubyGems generated it for us during gem installation? 🤔

Thanks for detailed description of the problem!

@mrexox, any thoughts?

@mrexox mrexox added the Windows Windows case label Aug 10, 2022
@mrexox
Copy link
Member

mrexox commented Aug 10, 2022

Hey @ariccio! The problem is that we assume that on Windows lefthook has actually lefthook.exe file as executable. But is seems like Ruby creates a wrapper lefthook.bat which executes a binary from the gem.

I would suggest installing lefthook with go install github.com/evilmartians/lefthook@latest instead of globally installed gem. This should fix the issue.

I will add a check for lefthook.bat for Windows also, and it should fix the problem.

@mrexox
Copy link
Member

mrexox commented Aug 10, 2022

Will release it in about a week as version 1.1.0

@mrexox mrexox added this to the 1.1.0 milestone Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Windows Windows case
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants