{"thread":{"id":"26928","subject":"error: cannot run hooks/pre-receive: No such file or directory","startedAt":"2011-03-30T13:27:14Z","lastAt":"2011-03-31T07:20:23Z","messageCount":4,"participants":["Mathieu Malaterre","Computer Druid","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"164688","messageId":"AANLkTinehsLJWYona7ONqquWpCZozr3hW-JNMhYz4Rvn@mail.gmail.com","threadId":"26928","inReplyTo":null,"subject":"error: cannot run hooks/pre-receive: No such file or directory","fromName":"Mathieu Malaterre","fromEmail":"mathieu.malaterre@gmail.com","sentAt":"2011-03-30T13:27:14Z","receivedAt":"2011-03-30T13:27:14Z","isPatch":false,"sender":{"key":"mathieu.malaterre@gmail.com","avatar":"https://gravatar.com/avatar/0728db14da3b5f9cb00476f504394196a14dac116214d8114f402fad0871bb86?d=mp&s=160"},"body":"Hi all,\n\n  I am trying to use a ruby script to reject commit with non-linear\nhistory (*). However it keeps failing with the following message:\n\n$ git push\nCounting objects: 5, done.\nDelta compression using up to 4 threads.\nCompressing objects: 100% (3/3), done.\nWriting objects: 100% (3/3), 304 bytes, done.\nTotal 3 (delta 2), reused 0 (delta 0)\nerror: cannot run hooks/pre-receive: No such file or directory\nTo ssh://malat@gdcm.git.sourceforge.net/gitroot/gdcm/gdcm.old\n ! [remote rejected] master -> master (pre-receive hook declined)\nerror: failed to push some refs to\n'ssh://malat@gdcm.git.sourceforge.net/gitroot/gdcm/gdcm.old'\n\nI tried with something as simple as :\n\n% cat pre-receive\n#!/usr/bin/ruby\n% which ruby\n/usr/bin/ruby\n\nDo I need to do something special with ruby ?\n\nThanks,\n-- \nMathieu\n"},{"id":"164704","messageId":"AANLkTimkVSL52Bhdhnu+OC8SWzfUJ7ZK0KBcydjG4wXT@mail.gmail.com","threadId":"26928","inReplyTo":"AANLkTinehsLJWYona7ONqquWpCZozr3hW-JNMhYz4Rvn@mail.gmail.com","subject":"Re: error: cannot run hooks/pre-receive: No such file or directory","fromName":"Computer Druid","fromEmail":"computerdruid@gmail.com","sentAt":"2011-03-30T18:35:11Z","receivedAt":"2011-03-30T18:35:11Z","isPatch":false,"sender":{"key":"computerdruid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/34696?v=4"},"body":"On Wed, Mar 30, 2011 at 9:27 AM, Mathieu Malaterre\n<mathieu.malaterre@gmail.com> wrote:\n> Hi all,\n>\n>  I am trying to use a ruby script to reject commit with non-linear\n> history (*). However it keeps failing with the following message:\n>\n> $ git push\n> Counting objects: 5, done.\n> Delta compression using up to 4 threads.\n> Compressing objects: 100% (3/3), done.\n> Writing objects: 100% (3/3), 304 bytes, done.\n> Total 3 (delta 2), reused 0 (delta 0)\n> error: cannot run hooks/pre-receive: No such file or directory\n> To ssh://malat@gdcm.git.sourceforge.net/gitroot/gdcm/gdcm.old\n>  ! [remote rejected] master -> master (pre-receive hook declined)\n> error: failed to push some refs to\n> 'ssh://malat@gdcm.git.sourceforge.net/gitroot/gdcm/gdcm.old'\n>\n> I tried with something as simple as :\n>\n> % cat pre-receive\n> #!/usr/bin/ruby\n> % which ruby\n> /usr/bin/ruby\nCheck that hooks/pre-receive is executable? (chmod +x)\n"},{"id":"164723","messageId":"20110330200442.GA30663@sigill.intra.peff.net","threadId":"26928","inReplyTo":"AANLkTinehsLJWYona7ONqquWpCZozr3hW-JNMhYz4Rvn@mail.gmail.com","subject":"Re: error: cannot run hooks/pre-receive: No such file or directory","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-03-30T20:04:42Z","receivedAt":"2011-03-30T20:04:42Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Mar 30, 2011 at 03:27:14PM +0200, Mathieu Malaterre wrote:\n\n> $ git push\n> Counting objects: 5, done.\n> Delta compression using up to 4 threads.\n> Compressing objects: 100% (3/3), done.\n> Writing objects: 100% (3/3), 304 bytes, done.\n> Total 3 (delta 2), reused 0 (delta 0)\n> error: cannot run hooks/pre-receive: No such file or directory\n> To ssh://malat@gdcm.git.sourceforge.net/gitroot/gdcm/gdcm.old\n>  ! [remote rejected] master -> master (pre-receive hook declined)\n> error: failed to push some refs to\n> 'ssh://malat@gdcm.git.sourceforge.net/gitroot/gdcm/gdcm.old'\n\nWe won't try to execute a hook that doesn't exist, so the \"no such file\nor directory\" almost certainly means the #! interpreter is missing.\n\n> I tried with something as simple as :\n> \n> % cat pre-receive\n> #!/usr/bin/ruby\n> % which ruby\n> /usr/bin/ruby\n\nThis might be a stupid question, but which machine is that output from?\nThe pre-receive hook runs on the server, so you must have ruby there. I\nask mainly because I didn't realize sourceforge would give people\narbitrary shell access on the git boxes.\n\nMy next guess would be that the git process runs in some kind of chroot\nthat doesn't have ruby in it.\n\n> Do I need to do something special with ruby ?\n\n>From git's perspective, no, but it may depend on how the server is\nconfigured.\n\n-Peff\n"},{"id":"164761","messageId":"AANLkTikb42kG8DyZ7KHhin+=1X72XvN9p-mjed0oJsk=@mail.gmail.com","threadId":"26928","inReplyTo":"20110330200442.GA30663@sigill.intra.peff.net","subject":"Re: error: cannot run hooks/pre-receive: No such file or directory","fromName":"Mathieu Malaterre","fromEmail":"mathieu.malaterre@gmail.com","sentAt":"2011-03-31T07:20:23Z","receivedAt":"2011-03-31T07:20:23Z","isPatch":false,"sender":{"key":"mathieu.malaterre@gmail.com","avatar":"https://gravatar.com/avatar/0728db14da3b5f9cb00476f504394196a14dac116214d8114f402fad0871bb86?d=mp&s=160"},"body":"On Wed, Mar 30, 2011 at 10:04 PM, Jeff King <peff@peff.net> wrote:\n> On Wed, Mar 30, 2011 at 03:27:14PM +0200, Mathieu Malaterre wrote:\n>\n>> $ git push\n>> Counting objects: 5, done.\n>> Delta compression using up to 4 threads.\n>> Compressing objects: 100% (3/3), done.\n>> Writing objects: 100% (3/3), 304 bytes, done.\n>> Total 3 (delta 2), reused 0 (delta 0)\n>> error: cannot run hooks/pre-receive: No such file or directory\n>> To ssh://malat@gdcm.git.sourceforge.net/gitroot/gdcm/gdcm.old\n>>  ! [remote rejected] master -> master (pre-receive hook declined)\n>> error: failed to push some refs to\n>> 'ssh://malat@gdcm.git.sourceforge.net/gitroot/gdcm/gdcm.old'\n>\n> We won't try to execute a hook that doesn't exist, so the \"no such file\n> or directory\" almost certainly means the #! interpreter is missing.\n>\n>> I tried with something as simple as :\n>>\n>> % cat pre-receive\n>> #!/usr/bin/ruby\n>> % which ruby\n>> /usr/bin/ruby\n>\n> This might be a stupid question, but which machine is that output from?\n> The pre-receive hook runs on the server, so you must have ruby there. I\n> ask mainly because I didn't realize sourceforge would give people\n> arbitrary shell access on the git boxes.\n>\n> My next guess would be that the git process runs in some kind of chroot\n> that doesn't have ruby in it.\n\nMakes complete sense now. I thought initially that the \"no such file\"\nrefered to the actual hooks script. I naively assumed my ssh\nconnection on sf.net gave me access to the actual git boxes (or maybe\nit is executed from a chroot).\n\nIn any case rewriting the script in pure shell script (no bash either)\nseems to work ok now (*).\n\nHowever I am now being told that this script should rather go in the\nupdate hooks...\n\n\n(*)\nread rev_old rev_new refname\n\nref_to_check=\"refs/heads/master\"\n\nif [ \"$refname\" == \"$ref_to_check\" ]\nthen\n  merge_bases=`git merge-base ${rev_old} ${rev_new}`\n  if [ \"$merge_bases\" != \"$rev_old\" ]\n  then\n    echo \"Non fastward is disallowed\"\n    exit 1\n  fi\n  # non-fast-forward case:\n  git rev-list --parents $merge_bases..$rev_new \\\n    | while read x; do\n      set -- $x\n      if [ \"$#\" != \"2\" ]\n      then\n        echo \"Multiple parents: $x\";\n        exit 1\n      fi;\n    done\n  [ $? -ne 0 ] && exit 1\nfi\nexit 0\n"}]}