git-up / GitUp

The Git interface you've been missing all your life has finally arrived.
http://gitup.co
GNU General Public License v3.0
11.44k stars 1.23k forks source link

GitUp throwing 'npx not found' error on commit #1006

Open gabcomby opened 4 weeks ago

gabcomby commented 4 weeks ago

The project I work on has a pre-commit hook which uses an npx command. When I use regular Git on my console, everything works fine. I use NVM, Noda 20, and running 'npx-v' correctly gives me the currently installed npx version, which shows it is indeed installed. However, when committing with GitUp, I get the following error: npx: command not found.

I tried reinstalling a fresh version of Node 20 with NVM, but to no avail. Any clues here?

Cykelero commented 4 weeks ago

It's likely that when it executes your hooks, GitUp doesn't have access to your environment variables, such as PATH; which in turn means it can't find the npx executable.

As a workaround (and a way to confirm this is indeed the cause!), you could try running the app through Terminal, which makes it inherit your shell's env variables:

$ nohup /Applications/GitUp.app/Contents/MacOS/GitUp > /dev/null 2>&1 &

(adjust the path depending on where you've installed the app)

gabcomby commented 4 weeks ago

@Cykelero when running the command, I get the following output, and my GitUp app doesn't launch: [1] 52887 [1] + exit 127 $ nohup /Applications/GitUp.app/Contents/MacOS/GitUp > /dev/null 2>&1

Cykelero commented 4 weeks ago

Sorry about the confusion: the $ isn't part of the command, it's supposed to represent a shell prompt! The actual command to copy and paste into Terminal starts at nohup, and it'll only work if GitUp is in the root Applications folder.

gabcomby commented 4 weeks ago

Yeah sorry that's on me, I wasn't really thinking lmao. It works great, now I'm able to commit freely. Is there any way to give GitUp access to my PATH? It would be rgeat if I could avoid having to launch it via Terminal every time...

Cykelero commented 4 weeks ago

I don't know of an easier workaround, sorry. GitUp would have to be updated with the ability to import your environment variables, but that's kind of thorny, as it can have side-effects.

(some resources if someone wants to work on that feature: Nova's support page on the subject; a SO answer with an example implementation; and another related SO answer)