0

A project clone from my Gogs web server, then I add a file to the Git repository,and push this commit to remote, but the terminal report error about cannot spawn hooks/pre-receive:No such file or directory .

I checked it and ensure the pre-receive file is exist in server-side git-repository, and the cloned had a file is named pre-receive.sample.

So, I don't know why does this happen and what I can do for resolve it. Please help.

server-side image:

server-side

client-side image:

client-side

system env: system env

Aurélien Gâteau
  • 4,010
  • 3
  • 25
  • 30
HanQ
  • 95
  • 1
  • 8

1 Answers1

0

pre-receive.sample is just that — a sample. Anyway pre-receive is meaningless on the client side so this part can be ignored or even removed from the question.

hooks/pre-receive on the server side is more interesting. It exists and it seems the server tries to run it but failed. I suspect there is a problem with the shebang — the 1st line of the script that points to interpreter (most probably the shell) to run the script. Please verify the shell exist on the server. For example if the shebang is #!/bin/bash verify there is /bin/bash file at the server and the file can be run. Fix the shebang — that is, point it to an existing shell like /bin/sh.

phd
  • 82,685
  • 13
  • 120
  • 165
  • I update the question description, it write '!#/user/bin/env bash' at 1st,and i already set bash in system env, but it still failed – HanQ Nov 30 '18 at 08:46