Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

"/bin/bash^M: bad interpreter: No such file or directory" whilst executing pre-commit hooks #1036

Closed
Xapphire13 opened this issue Jul 15, 2017 · 2 comments
Labels

Comments

@Xapphire13
Copy link
Contributor

Description

When executing pre-commit hooks I get the following error:

Unable to commit
.git/hooks/pre-commit: /f/***/***/***/***/.git/hooks/pre-commit.extension.***.GitHooks: /bin/bash^M: bad interpreter: No such file or directory

(Path above is obfuscated)

Reproduces how often:

Always

Versions

OS: Windows 10 x64
Atom: 1.18.0 x64
Atom-GitHub: 0.3.3

Additional info

Spoke with @BinaryMuse who linked me to this on StackOverflow which shows people seeing a similar non-atom related issue

I will try to debug and find more info if I can

@Xapphire13
Copy link
Contributor Author

Xapphire13 commented Jul 15, 2017

Figured out the root cause. Since i am using Windows, the git pre-commit hooks I have, have CRLF endings. This works when using git via the command line, however breaks when using via atom/github due to its dependence on dugite. When using git via dugite on a Windows machine the PATH variable is prefixed with the mingw tools distributed with git (see here), which expects UNIX style LF endings.

The quick solution for me, is to convert all of my team's pre-commit hooks to LF style endings. I'm unsure if this is anything the Atom team can do however.

@Xapphire13
Copy link
Contributor Author

Xapphire13 commented Jul 17, 2017

Update: The line endings were just a red-herring. The actual issue was the specified interpreter of #!/bin/bash

Irrespective of line endings, the issue is fixed when changed to #!/bin/sh. So my team's pre-commit hooks were just configured incorrectly. I'm assuming this doesn't manifest in the command line because PowerShell and cmd (presumably) ignore the #! lines in the script, but mingw doesn't.

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

No branches or pull requests

2 participants