You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Visual Studio (Not VS Code!) fails to execute our pre-commit hook because it cannot execute our shebang (#!/usr/bin/env bash).
Steps to reproduce:
Install a global pre-commit hook with ggshield install -t pre-commit -m global
Start Visual Studio
Try to commit from within Visual Studio
Actual result:
Expected result:
Pre-commit hook should run and commit should be scanned.
One can workaround that by replacing the shebang with #!/bin/sh. However it's not a correct fix because the hook uses bash-specific syntax so it would fail on OS where /bin/sh is not bash, such as Ubuntu.
TODO
Replace all our hook shebangs with #!/bin/sh. Note that using #!/usr/bin/env sh does not fix the problem
Fix the bashims
If possible, setup a check like checkbashisms or shellcheck in the CI
I am not sure to understand why this issue is limited to Visual Studio users ?
From my understanding, any user with the global pre-commit hook installed but without bash available will fail to execute the hook ?
I think that's because VS ships with its own version of Git, which wrongly assumes that a script to be executed with bash must be Linux only, so it must go through WSL.
Visual Studio thinks a script starting with "#!/usr/bin/env bash" (or
"#!/usr/bin/bash" or "#!/bin/bash") must be run using WSL. Work-around
this by using Posix shell only and a "#!/bin/sh" shebang.
Fixes#467
Environment
Describe the bug
Visual Studio (Not VS Code!) fails to execute our pre-commit hook because it cannot execute our shebang (
#!/usr/bin/env bash
).Steps to reproduce:
ggshield install -t pre-commit -m global
Actual result:
Expected result:
Pre-commit hook should run and commit should be scanned.
One can workaround that by replacing the shebang with
#!/bin/sh
. However it's not a correct fix because the hook uses bash-specific syntax so it would fail on OS where /bin/sh is not bash, such as Ubuntu.TODO
#!/bin/sh
. Note that using#!/usr/bin/env sh
does not fix the problemRelated issue on pre-commit: pre-commit/pre-commit#2182
The text was updated successfully, but these errors were encountered: