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

It's failed in git GUI #1041

Closed
NSGUF opened this issue Sep 10, 2021 · 15 comments
Closed

It's failed in git GUI #1041

NSGUF opened this issue Sep 10, 2021 · 15 comments

Comments

@NSGUF
Copy link

NSGUF commented Sep 10, 2021

It's failed in git GUI

when i use GUI, eslint failed, but commit succeeded;
westorm、vscode、terminal can intercept,but gui can't;

"husky": "^7.0.1",

@thany
Copy link

thany commented Sep 13, 2021

This is a blithering awful issue description. But, he's right. Hooks work perfectly in the CLI, but not in "GUI", and for me the GUI means GitKraken.

I've also reported it to them. The precommit hook, at least, does get executed when committing from within VScode (graphically, not the CLI in VScode... obviously) so I'm guessing GitKraken is doing something wrong. How the hell they convince Git to commit without executing hooks? Your guess is as good as mine, but they are definitely messing something up.

And this may be the case for @NSGUF as well, even with that much detailed information and environmental context.

@typicode
Copy link
Owner

It's a known issue on GitKraken
#875

Unfortunately nothing that could be done on husky's side.

As for the other problem, I'd suggest checking https://typicode.github.io/husky/#/?id=command-not-found as it's often a PATH problem.

@sholladay
Copy link

It's a regression that the Husky maintainers just don't want to fix.

See: #639

@mlbiche
Copy link

mlbiche commented Sep 23, 2021

Seems to be fixed in GitKraken 8

@thany
Copy link

thany commented Sep 24, 2021

Nice, thanks for staying on the ball 🙂

@penx
Copy link

penx commented Oct 18, 2021

I had this issue with v4 and followed the solution provided by @typicode here:

#639 (comment)

This issue has resurfaced with v7 and it appears the recommended contents of ~/.huskyrc has since changed:

https://typicode.github.io/husky/#/?id=command-not-found

Updating ~/.huskyrc fixed the issue for me, but as per my comment on #639 I would prefer if Husky did not require users to set up a ~/.huskyrc manually in order to run hooks from within a Git GUI such as Tower, Kraken, VSCode.

If you have a project with 3rd party contributors, or a large number of internal contributors, it's not particularly feasible to ask everyone to make sure they have a .huskyrc file set up in order to successfully run git hooks.

The fact that this fails silently means contributors will not be made aware if they missed this step.

#639 (comment)

@sholladay
Copy link

Still happily staying on Husky v3, years later.

Wrestlers shouting 'for life'

@Naddiseo
Copy link

Naddiseo commented Nov 29, 2021

Another workaround I found is a little bash file to fill in the .git/hooks files and make them run the husky hooks:

#!/bin/sh
# ./hook_setup.sh
set -e

HERE=$(realpath $(dirname "$0"))
GITDIR="$HERE/.git"
HOOKDIR="$GITDIR/hooks"
HUSKY_HOOKS="$HERE/.husky"

for F in `ls "$HUSKY_HOOKS"`; do
    P="$HUSKY_HOOKS/$F"
    if [ -f "$P" ] ; then
        HOOK_FILE="$HOOKDIR/$F"
        echo "#!/bin/sh" > "$HOOK_FILE"
        echo "sh \"$P\"" >> "$HOOK_FILE"
        chmod +x "$HOOK_FILE"
    fi
done

then call it in the prepare script:

{
    "scripts": {
        "prepare": "husky install && sh hook_setup.sh"
    }
}

@stale
Copy link

stale bot commented Jan 28, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jan 28, 2022
@Naddiseo
Copy link

still an issue

@typicode
Copy link
Owner

I'm going to close this issue as it seems to be fixed in GitKraken now:
https://davideimola.com/git-hooks-gitkraken-client-husky-nvm/

As for why it doesn't work in GUI (and how to fix it) the article explains it very well:

Node version manager work by modifying the PATH when the terminal is started. For this reason, GUI clients usually do not work well whit those managers as they are not sourcing .zshrc or .bashrc files where nvm is initialized.

If you install node globally (without nvm) you shouldn't have this issue though.

@Naddiseo
Copy link

I'm going to close this issue as it seems to be fixed in GitKraken now: https://davideimola.com/git-hooks-gitkraken-client-husky-nvm/

As for why it doesn't work in GUI (and how to fix it) the article explains it very well:

Node version manager work by modifying the PATH when the terminal is started. For this reason, GUI clients usually do not work well whit those managers as they are not sourcing .zshrc or .bashrc files where nvm is initialized.

If you install node globally (without nvm) you shouldn't have this issue though.

I'm not using nvm :)
the issue with git gui seems to be that it doesn't use core.hookPath so I've been relying on the little script I posted a few replies back to run on the "prepare" script to install husky properly

@sholladay
Copy link

sholladay commented Feb 23, 2022

I'm also not using nvm. I have Node and npm installed globally via Homebrew. Nothing fancy about the setup, just the default installation location. Husky doesn't work in any GUI with a default Node install.

@typicode
Copy link
Owner

@sholladay
Copy link

No, because:

  1. I assume there is a reason that macOS is designed that way.
  2. I don't want to make such modifications to all of the machines that I interact with on an ongoing basis. It's not ergonomic, among other reasons.

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

7 participants