gabyx / Githooks

🦎 Githooks: per-repo and shared Git hooks with version control and auto update. [✩Star] if you're using it!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

install.sh doesn't work on MacOS (Sonoma at least)?

skaurus opened this issue · comments

I'm actually trying to uninstall the hooks, because I ended up not using them.

That's what I get:

bash ./install.sh --uninstall
./install.sh: line 12: local: -n: invalid option
local: usage: local name[=value] ...

And even if I run bash manually and try to execute the script from there, it is the same:

bash-3.2$ ./install.sh --uninstall
./install.sh: line 12: local: -n: invalid option
local: usage: local name[=value] ...

I've installed the hooks a long way ago, and don't remember having any problems back then. It was a couple MacOS releases back, I think... at least one.

I found somewhere else that a newer bash is required to support the local -n flag. So, brew install bash and a new try...

./install.sh --uninstall
./install.sh: line 105: die: command not found

I see from the script source that this die is related to CPU arch check; I'm on Macbook Pro M1, btw.

uname -m
arm64

But as far as I can tell, the script actually supports arm64?..

Ah, I see. The script first looks if there is x86_64 in the uname -m output; then if there is aarch64 in the same command output; and then if there is arm64 in the uname -p output, note the different flag.

And:

uname -p
arm

I've tried to simply change uname -p to uname -m. No luck:

./install.sh --uninstall
!! Unsupported operating system 'darwin' or
 machine type 'arm64':
 Please check 'https://github.com/gabyx/githooks/releases' manually.

I gather it is because there is no release with darwin in it's name here: https://github.com/gabyx/githooks/releases

I replaced this (line 22):

    elif [[ "$OSTYPE" == "darwin"* ]]; then
        _platformOS="darwin"

with this:

    elif [[ "$OSTYPE" == "darwin"* ]]; then
        _platformOS="macos"

And the script failed saying that the command die on the line 76 is not found.

So, I replaced darwin with macos on the line 64 as well.

After that it worked, and complained that I don't have the .githooks folder in my home dir and so I have a broken installation.
Probably, the first time I tried to uninstall githooks manually, by cleaning up my .gitconfig and this dir, and that is why I have problems now. I feel like prooooobably I did that because I couldn't find word "uninstall" in the README back then, but I could have just missed it. Or I could have looked in the wrong repository, like https://github.com/rycus86/githooks...

It still offered to continue uninstalling, and after that, clone went without the error.

Hope this thread will be helpful!

I think I can fix this in my PR #129