husky-elixir icon indicating copy to clipboard operation
husky-elixir copied to clipboard

husky.install to look for .git/hooks folder in cwd

Open anoopmadhav opened this issue 5 years ago • 10 comments

To fix the below mentioned error

... running 'husky.install' task
** (RuntimeError) '/home/.git' directory does not exist. Try running $ git init
    lib/husky/task/install.ex:40: Mix.Tasks.Husky.Install.create_scripts/2
    (mix) lib/mix/task.ex:301: Mix.Task.run_task/3
    (mix) lib/mix/cli.ex:75: Mix.CLI.run_task/2
    (elixir) lib/code.ex:376: Code.require_file/2

anoopmadhav avatar Aug 26 '19 14:08 anoopmadhav

Looks like the build failed, can you run mix format

spencerdcarlson avatar Aug 27 '19 04:08 spencerdcarlson

@spencerdcarlson My bad. formatted the code. Build passing now.

anoopmadhav avatar Aug 27 '19 07:08 anoopmadhav

I need to double check this. I'm thinking maybe we use

'git rev-parse --show-toplevel' 
|> :os.cmd() 
|> to_string()

to find the closest .git root

spencerdcarlson avatar Aug 29 '19 02:08 spencerdcarlson

Using git command makes more sense.

anoopmadhav avatar Sep 09 '19 22:09 anoopmadhav

Status update on this PR?

zchbndcc9 avatar Dec 05 '19 19:12 zchbndcc9

@spencerdcarlson I have made the changes, could you check it once.

anoopmadhav avatar Dec 06 '19 07:12 anoopmadhav

I also encountered this issue on my Mac.

mix husky.install
... running 'husky.install' task
** (RuntimeError) '/Users/don/.git' directory does not exist. Try running $ git init
    lib/husky/task/install.ex:40: Mix.Tasks.Husky.Install.create_scripts/2
    (mix 1.10.4) lib/mix/task.ex:330: Mix.Task.run_task/3
    (mix 1.10.4) lib/mix/cli.ex:82: Mix.CLI.run_task/2
    (elixir 1.10.4) lib/code.ex:926: Code.require_file/2

I can confirm that changing to this branch solves the issue for me.

darksheik avatar Jul 22 '20 16:07 darksheik

sorry to bump an old thread, but any chance this could get merged into main @spencerdcarlson? I'm encountering the same problem as darksheik, would rather not point my dep to a branch to fix. Thank you :)

newt-beach avatar Aug 10 '22 15:08 newt-beach

Hey, I'm running into the same problem as well, could this be merged please? I would rather not point my app to a branch or change my git hooks to a different library.

ShivamBang98 avatar Dec 10 '23 20:12 ShivamBang98

Any updates on this i have the same issue ?!

helderjnpinto avatar Jun 05 '24 13:06 helderjnpinto