ericpaulbishop / redmine_git_hosting

A ChiliProject/Redmine plugin which makes configuring your own git hosting easy.
186 stars 37 forks source link

remote: /usr/bin/env: rubyerror: cannot run hooks/post-receive: No such file or directory: No such file or directory #150

Closed jehoshua02 closed 12 years ago

jehoshua02 commented 12 years ago

I create a new project called test. I make sure I'm a member, and that I have a public key. Then I create the repo in ChiliProject. But then, when I follow the steps to push to the new repo, I get an error:

js@JS-LAPTOP /d/projects/test (master)
$ git push -u origin master
Enter passphrase for key '/c/Users/js/.ssh/id_rsa':
Counting objects: 3, done.
Writing objects: 100% (3/3), 210 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
error: cannot run hooks/post-receive: No such file or directoryremote: /usr/bin/env:

To git@192.168.1.7:test.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.
jehoshua02 commented 12 years ago

I edit a file, add, commit, then push. I get an different error:

js@JS-LAPTOP /d/projects/test (master)
$ git commit -m 'some text'
[master 5bddfa0] some text
 1 files changed, 1 insertions(+), 0 deletions(-)

js@JS-LAPTOP /d/projects/test (master)
$ git push origin master
Enter passphrase for key '/c/Users/js/.ssh/id_rsa':
Counting objects: 5, done.
Writing objects: 100% (3/3), 248 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
error: cannot run hooks/post-receive: No such file or directory
ruby: No such file or directory
To git@192.168.1.7:test.git
   87da078..5bddfa0  master -> master
jehoshua02 commented 12 years ago

Curious about this, so I created another project, test2, and followed the steps to push the first commit:

js@JS-LAPTOP /D/projects/test2 (master)
$ git push -u origin master
Enter passphrase for key '/c/Users/js/.ssh/id_rsa':
Counting objects: 3, done.
Writing objects: 100% (3/3), 233 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
error: cannot run hooks/post-receive: No such file or directory
: No such file or directory
To git@192.168.1.7:test2.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.
jehoshua02 commented 12 years ago

Created a third project, test3, set up the repo, and pushed the first commit:

js@JS-LAPTOP /D/projects
$ mkdir test3

js@JS-LAPTOP /D/projects
$ cd test3/

js@JS-LAPTOP /D/projects/test3
$ git init
Initialized empty Git repository in d:/projects/test3/.git/

js@JS-LAPTOP /D/projects/test3 (master)
$ vim readme.md

js@JS-LAPTOP /D/projects/test3 (master)
$ git add .

js@JS-LAPTOP /D/projects/test3 (master)
$ git commit -m 'first commit'
[master (root-commit) b1d9369] first commit
 1 files changed, 3 insertions(+), 0 deletions(-)
 create mode 100644 readme.md

js@JS-LAPTOP /D/projects/test3 (master)
$ git remote add origin git@192.168.1.7:test3.git

js@JS-LAPTOP /D/projects/test3 (master)
$ git push -u origin master
Enter passphrase for key '/c/Users/js/.ssh/id_rsa':
Counting objects: 3, done.
Writing objects: 100% (3/3), 250 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: /usr/bin/env: rubyerror: cannot run hooks/post-receive: No such file or directory: No such file or directory
To git@192.168.1.7:test3.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.
jehoshua02 commented 12 years ago

The same error appears again after pushing another commit on test3, but it seems the other test error message had a slightly different error message, but in all cases, mentions the hooks/post-receive, about which, I don't even know where to start looking to fix it.

jehoshua02 commented 12 years ago

I wonder what problems this will create?

I will pay you something to give this attention.

three18ti commented 12 years ago

This is the same error here: https://github.com/ericpaulbishop/redmine_git_hosting/issues/125

Did you install ruby using RVM?

three18ti commented 12 years ago

Also, you might find this relevant:

https://github.com/ericpaulbishop/redmine_git_hosting/issues/148

Again, I encountered all of these problems because I installed Ruby with RVM. Pretty sure you did the same.

jehoshua02 commented 12 years ago

I did install ruby using RVM, but I'm not convinced everybody here is experiencing the exact same issue. So if you don't mind, I'd like to carefully rule out the possibilities . . .

. . . I guess I'd start by checking if "hooks/post-receive" truly doesn't exist, no? But the error message doesn't tell me exactly where it's looking for this "hooks/post-receive".

So, how do I know, for certain, the location of the "hooks/post-receive" to which the error message refers?

jehoshua02 commented 12 years ago

In addition to the previous question:

What exactly is the "hooks/post-receive" supposed to do anyway? And what puts it there? How?

Just guessing: It somehow notifies chili that there's been a commit so it can expire cache, and it's put there by the redmine_git_hosting plugin. How it puts it there, I'm not sure.

Does anybody know for sure?

jehoshua02 commented 12 years ago

SOLUTION: symlink chili's ruby into git's path

After sifting through ramblings in other issues that seem closely related, I found a decent, non-intrusive solution.

I installed ruby as chili using rvm, which installs it under the chili home directory. Thus it's not in the path for other users, which is why ~git/.gitolite/hooks/common/post-receive can't find it, because it's not in path for git user.

[git@projects ~]$ which ruby
/usr/bin/which: no ruby in (/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/git/bin)

My work around was to simply create a symlink to chili's ruby in /usr/local/bin, like so:

[root@projects ~]# cd /usr/local/bin
[root@projects bin]# ln -s `sudo -u chili -i which ruby`
[root@projects bin]# ll
total 0
lrwxrwxrwx 1 root root 50 Feb  8 09:15 ruby -> /home/chili/.rvm/rubies/ree-1.8.7-2012.01/bin/ruby

Then I checked to see if git can now see ruby:

[git@projects ~]$ which ruby
/usr/local/bin/ruby
EspadaV8 commented 12 years ago

That will work, but isn't a good solution.

You're forcing a system symlink (/usr/local/bin) to a file in a users home directory. Any user other than 'chili' won't have access to it because of permissions on /home/chili

If you've installed RVM as a user then you should also install RVM as the git user as well and keep them apart. If you've installed it as a root user then RVM should be fixed so that it adds the default ruby into a standard folder that's in $PATH by default (like /usr/local/bin).

jehoshua02 commented 12 years ago

For my particular setup, it's an excellent solution.

I don't have to install anything else, anywhere else. It's all contained in the chili user.

I wanted to make sure the git user was using the same ruby as chili, without tampering with the git user.

It's unobtrusive.

However, there may be a better place to put the symlink so that it doesn't affect other users. But this server is dedicated for chiliproject and there are only two users, git and chili.

Furthermore, I won't be doing anything else with ruby on this system anyway. Just chiliproject.

So in my particular case, it's the perfect solution (crossing my fingers, hoping nothing else goes wrong). The whole install process was a nightmare, I'm ready to move on to actually using chiliproject, rather than weighing out all the alternative solutions.

So if you don't mind, I found my solution.

Feel absolutely free to offer up alternative solutions, but please be careful what you call "not good".

On Feb 8, 2012 6:44 PM, "Andrew Smith" < reply@reply.github.com> wrote:

That will work, but isn't a good solution.

You're forcing a system symlink (/usr/local/bin) to a file in a users home directory. Any user other than 'chili' won't have access to it because of permissions on /home/chili

If you've installed RVM as a user then you should also install RVM as the git user as well and keep them apart. If you've installed it as a root user then RVM should be fixed so that it adds the default ruby into a standard folder that's in $PATH by default (like /usr/local/bin).


Reply to this email directly or view it on GitHub: https://github.com/ericpaulbishop/redmine_git_hosting/issues/150#issuecomment-3880375

EspadaV8 commented 12 years ago

I didn't mean to imply that it wouldn't, more that it isn't robust and would likely break with for others.

If it's working for your system then by all means stick with it (if it ain't broke...), but I wouldn't advise it as a general solution to others.