Git - remote: error: cannot run hooks/post-receive: No such file or directory
Check if you have the the correct 775 permissions.
For me it worked by redoing the folder structure with
git init --bare
This would happen if the hooks/post-receive
file exists, is marked executable, but cannot be executed. It cannot be executed, because the interpreter, /bin/bash2
, either does not exist or is not executable.
Replace the /bin/bash2
with name of bash that does exist and is executable on the server.
(The reason the error looks like this is, that the operating system only returns the error status, "No such file or directory", but does not report which file does not exist. And the code that tried to execute it does not know that the system already read hooks/post-receive
and was looking for /bin/bash2
. All it knows is it tried to run hooks/post-receive
, so that's what it prints).
In addition (for future reference and documentation on this question) if you were to run echo $SHELL
in your shell you should see an expected result, in this case (based on the approved answer) you would expect /bin/bash
as your result. But another possible problem can be an unseen carriage return.
Try running hooks/post-receive
if you're still having issues, you may get a response like this:
-bash: hooks/post-receive: /bin/bash^M: bad interpreter: No such file or directory
The key here is the ^M
that is proof that you are in fact getting an unexpected carriage return, otherwise if it had worked you would probably get a hanging response.
Fix that and it should fix your problem. The way to do that, use dos2unix
, for example:
dos2unix .htaccess