Sublime Forum

Husky pre-commit hook failing in Sublime Merge

#1

I’m using the tailwind-nextjs-starter-blog project and it uses husky to do pre-commit linting. This works fine on the command line, but within Sublime Merge commits fail with the following error:

.husky/pre-commit: line 4: npx: command not found
husky - pre-commit hook exited with code 127 (error)

I presume this means that npx wasn’t found in the app’s PATH, similar to this earlier thread. On my system, npx is at ~/.asdf/shims/npx and the PATH in SM as reported by Help > Debug Information is:

PATH: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin (from shell)

I tried following the Homebrew suggestion from this other post and ran this in the Terminal:

sudo launchctl config user path "${HOME}/.asdf/shims:${PATH}"

I then restarted the system, but Sublime Merge’s PATH hasn’t changed, and commits from within SM still fail with the same error.

Any suggestions?

1 Like

#2

So, Sublime Merge had re-launched because it was open when I restarted. The PATH hadn’t changed. However, then I ran echo $PATH in Terminal and re-started Sublime Merge. And now the SM PATH contains all the directories in my shell, including ~/.asdf/shims/. And indeed, now git is committing successfully.

So my best guess is that the auto-re-launched app had retained the user PATH from the previous launch, and I needed to actually quit and re-launch it again to get the updated PATH. Anyway, I hope this helps someone in the future.

1 Like

#4

Well, I’d hope that it won’t actually be deleted. Other people will certainly run into this, and this solution isn’t fully documented elsewhere.

1 Like