On commiting my changes, I keep getting a command not found in PATH error
Opened this issue · 4 comments
The problem
Every time I try to commit my changes by pressing the "Commit to {branch name}" button, I get a command not found in PATH error. I have some pre-commit hooks configured using Husky. These hooks use yarn, and the error points to yarn not being found in PATH.
This is weird because
- Committing files works normally when I do it with the terminal (
git commit -m 'something') - Echo-ing my
$PATHdoes show/home/roj/.nvm/versions/node/v18.18.2/bin. The PATH for Github Desktop does not!
Release version
3.3.12-linux2 amd64
Operating system
Ubuntu 22.04.4 LTS x86_64
Steps to reproduce the behavior
- Have a pre-commit hook that uses
yarn. In my case I doyarn lintwhich simply runs Prettier to check for lint warnings. - Open
github-desktop, add some changes and add commit message - Press on "Commit to {branch name}"
Log files
.husky/pre-commit: 4: yarn: not found
husky - pre-commit hook exited with code 127 (error)
husky - command not found in PATH=/usr/lib/github-desktop/resources/app/git/libexec/git-core:/home/roj/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/roj/.local/share/JetBrains/Toolbox/scripts
Screenshots
No response
Additional context
No response
- Committing files works normally when I do it with the terminal
Could there be something terminal specific that isn't present when you launch GitHub Desktop via the OS launcher? Or are you launching it via the terminal and somehow the PATH values don't match?
It does look like some parts of the PATH that GitHub Desktop has are present - where is yarn meant to be located that it isn't part of this PATH value?
@shiftkey Okay, it seems that if I run $ github-desktop on my terminal (kitty) and try committing changes it works fine. The problem only arises when I open Github Desktop manually from my OS launcher. For the meanwhile I can continue like this :)
yarn's containing folder not being part of PATH is really weird. It's in /home/roj/.nvm/versions/node/v18.18.2/bin, which is in the PATH for zsh (and bash if that matters). The default terminal for Github Desktop is GNOME Terminal, which runs zsh and yarn works as expected as an executable.
Is it possible that github-desktop is somehow overwriting my PATH to something else?
Output from echo $PATH
/home/roj/.nvm/versions/node/v18.18.2/bin:/home/roj/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/roj/.local/share/JetBrains/Toolbox/scripts:/var/lib/flatpak/app/dev.zed.Zed/x86_64/stable/29feaf6558a8c888be0fba1f474731bb7775cee82c1dfd126e724122c643e3e7/files/bin
Note that the /usr/lib/github-desktop/resources/app/git/libexec/git-core path isn't in my actual PATH.
Note that the
/usr/lib/github-desktop/resources/app/git/libexec/git-corepath isn't in my actual PATH.
That's expected - when the app is executing Git commands we want to use the version that the app ships, so prefixing path with that value means it'll be preferred over the app.
yarn's containing folder not being part of PATH is really weird. It's in/home/roj/.nvm/versions/node/v18.18.2/bin, which is in the PATH for bothzshandbash(if that matters). The default terminal for Github Desktop is GNOME Terminal, which runs zsh andyarnalso runs as expected as an executable.
I think when using the OS launcher to launch an app it doesn't need a shell, so registering the PATH in a different location would be necessary to get that working. Seeing other tools like JetBrains mentioned in the Desktop error makes me suspect there's a different location at play related to your profile (which your shell is then prepending values to during it's setup), but how to get that to play well with nvm is something I don't have bandwidth to dig into currently.
