DEV Community


Using husky's pre-commit hook with a GUI

Remi Vledder
・2 min read

Husky is a tool which enables you to create git hooks easy.

With a hook you could for example make code linting and code formatting mandatory on the developers machine instead of doing that on the CI service.

I found that setting up husky following husky's documentation does not work out of the box for Git Graphical User Interfaces (GUI).

How to enable husky pre-commit hooks for Git GUI's

To enable this feature for a GUI such as Tower or sourcetree follow these steps:

Create a .huskyrc file in your OSX home directory (~/). Open your terminal and run the following commands:

$ cd ~/
$ touch .huskyrc
$ vi huskyrc
Enter fullscreen mode Exit fullscreen mode

Press i to enter vim's instert mode. Copy paste the following line:

Enter fullscreen mode Exit fullscreen mode

Press esc. Then : and wq. Finally press enter.

Now doing a commit in a GUI should show you the issues with the code when doing a commit:


Download gist


How to solve dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.60.dylib

Adding the path to the husky file enables husky, but initially it gave the following error on my machine:

dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.64.dylib
  Referenced from: /usr/local/bin/node
  Reason: image not found
.git/hooks/ line 15: 90006 Abort trap: 6           "$@" husky-run $hookName $gitParams
Enter fullscreen mode Exit fullscreen mode

You can upgrade node to resolve this issue:

$ brew upgrade node
Enter fullscreen mode Exit fullscreen mode


When using a node version package manager make sure to also include the following lines to .huskyrc:

# this loads and sets the correct PATH before running hook
. ~/.nvm/
Enter fullscreen mode Exit fullscreen mode

Discussion (2)

rekomat profile image
René Keller

Thanks Remi, you made my day.
BTW: The first code snippet in the article is missing a dot. Line 3 should read $ vi .huskyrc, not huskyrc).

happy profile image
Matúš Šťastný

Thanks! You saved my nerves 🙂