Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On commiting my changes, I keep getting a command not found in PATH error #1108

Open
rrojan opened this issue Aug 11, 2024 · 4 comments
Open

Comments

@rrojan
Copy link

rrojan commented Aug 11, 2024

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

  1. Committing files works normally when I do it with the terminal (git commit -m 'something')
  2. Echo-ing my $PATH does 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

  1. Have a pre-commit hook that uses yarn. In my case I do yarn lint which simply runs Prettier to check for lint warnings.
  2. Open github-desktop, add some changes and add commit message
  3. 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

@shiftkey
Copy link
Owner

  1. 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?

@rrojan
Copy link
Author

rrojan commented Aug 12, 2024

@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?

PATH that comes up in error:
image

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.

@shiftkey
Copy link
Owner

Note that the /usr/lib/github-desktop/resources/app/git/libexec/git-core path 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 both zsh and bash (if that matters). The default terminal for Github Desktop is GNOME Terminal, which runs zsh and yarn also 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.

@rrojan
Copy link
Author

rrojan commented Aug 20, 2024

@shiftkey After looking around a lot I was still unable to find the path that github-desktop was taking - I looked at all environment, profile files, etc.

For the meanwhile I've symlinked my node binaries to /usr/local/bin, which works around the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants