Commits work from the terminal, but from VS Code or a GUI client they fail with `husky - pre-commit script failed (code 127)` / `npx: command not found`.
IntermediateTroubleshootingSubmodules, LFS and Hooks
Answer
Likely causes → GUI apps don't load your shell profile, so tools installed via nvm, asdf, volta or Homebrew are not on the PATH the hook sees. Exit code 127 means "command not found".
Diagnose → Add echo $PATH > /tmp/hook-path.txt at the top of the hook and commit from the GUI.
Fix → For Husky v9, put PATH setup in ~/.config/husky/init.sh (sourced before each hook):
# ~/.config/husky/init.sh
export NVM_DIR="$HOME/.nvm"
. "$NVM_DIR/nvm.sh"
Or launch the editor from a terminal (code .) so it inherits your PATH.
Prevent → Keep hooks dependency-light and document the GUI PATH fix in the contributing guide.
More on Submodules, LFS and Hooks
`fatal: No url found for submodule path 'libs/common' in .gitmodules`IntermediateAfter cloning, the submodule directories exist but are empty.Beginner`git submodule update` fails: `fatal: remote error: upload-pack: not our ref 3f2a9c1...` and `Fetched in submodule path 'libs/common', but it did not contain 3f2a9c1. Direct fetching of that commit failed.`Intermediate`git status` keeps showing `modified: libs/common (new commits)` even though you never touched it.BeginnerYou committed inside a submodule, ran `git submodule update`, and your commits vanished.Intermediate`git submodule add` fails with `fatal: 'libs/common' already exists in the index`.Intermediate