redmine-git-hosting / redmine_git_hosting

A Redmine plugin which makes configuring your own Git hosting easy ;)
http://redmine-git-hosting.io
MIT License
275 stars 116 forks source link

Redmine shows that git cannot be found #111

Closed hexblot closed 10 years ago

hexblot commented 10 years ago

Hello,

followed the instructions, with the exception of gitolite being installed via yum (using gitolite2 ). Going to the "Config test" tab in the plugin administration says that everything is ok:

Required Permissions

Git user is able to sudo to Redmine user?True Redmine user is able to sudo to Git user?True PATH Directories /usr/lib64/ruby/gems/1.8/bin /sbin /usr/sbin /bin /usr/bin

Gitolite Version : 2 hello redmine_gitolite, this is gitolite 2.3.1-1.el6 running on git 1.7.1

the gitolite config gives you the following access: R W gitolite-admin @R @W testing

git is also installed via yum, and is available to the user by the global path ( /usr/bin/git ).

The problem is that on the Redmine settings page, I get an error for git, with no explanation other than : /[path_to_redmine]/plugins/redmine_git_hosting/bin/run_git_cmd_as_gitolite_user

running that script as the redmine user from shell works : /[path_to_redmine]/plugins/redmine_git_hosting/bin/run_git_cmd_as_gitolite_user --version

outputs : git version 1.7.1

so I assume it is working. Am I missing something? Thank you in advance!

hexblot commented 10 years ago

oddly enough, after a day of doing... nothing (I just quit on it), it actually works just fine :S sorry to bother people, don't know if this is going to be helpful at all...

n-rodriguez commented 10 years ago

No problem! I'm glad to see it's working :)

redirect11 commented 10 years ago

I'm using de latest devel version and i can't run commands with that executable:

redmine@localhost:~$ plugins/redmine_git_hosting/bin/run_git_cmd_as_gitolite_user --version
git: '"--version"' is not a git command. See 'git --help'.

and i can't create repos (i have the problem hexbolt have).

Also have:

2014-03-19 16:52:50 +0000 ERROR [GitHosting] Problems to retrieve Gitolite hook parameters in Gitolite config
2014-03-19 16:52:50 +0000 INFO [GitHosting] Testing if Gitolite user 'git' can sudo to Redmine user 'redmine'...
2014-03-19 16:52:50 +0000 INFO [GitHosting] OK!
2014-03-19 16:52:50 +0000 INFO [GitHosting] Testing if Redmine user 'redmine' can sudo to Gitolite user 'git'...
2014-03-19 16:52:51 +0000 INFO [GitHosting] OK!
2014-03-19 16:52:52 +0000 ERROR [GitHosting] Problems to retrieve Gitolite hook parameters in Gitolite config
2014-03-19 16:52:52 +0000 INFO [GitHosting] Set Git hooks global parameter : redmineurl (http://xxx/redmine/githooks/post-receive)
2014-03-19 16:52:52 +0000 ERROR [GitHosting] Error while setting Git hooks global parameter : redmineurl (http://xxx/redmine/githooks/post-receive)
2014-03-19 16:52:52 +0000 INFO [GitHosting] Set Git hooks global parameter : debugmode (false)
2014-03-19 16:52:52 +0000 ERROR [GitHosting] Error while setting Git hooks global parameter : debugmode (false)
2014-03-19 16:52:52 +0000 INFO [GitHosting] Set Git hooks global parameter : asyncmode (false)
2014-03-19 16:52:53 +0000 ERROR [GitHosting] Error while setting Git hooks global parameter : asyncmode (false)

i don't know how to solve these above... and:

2014-03-19 17:15:49 +0000 WARN [GitHosting] Hook 'post-receive.redmine_gitolite.rb' is already present but it's not ours!
2014-03-19 17:15:49 +0000 INFO [GitHosting] Restoring 'post-receive.redmine_gitolite.rb' hook since forceInstallHook == true
2014-03-19 17:15:49 +0000 INFO [GitHosting] Installing hook '/data/dicet_napoli/servizi/redmine/plugins/redmine_git_hosting/contrib/hooks/post-receive.redmine_gitolite.rb' in '~/.gitolite/hooks/common/post-receive'
2014-03-19 17:15:50 +0000 INFO [GitHosting] Hook 'post-receive.redmine_gitolite.rb' installed
2014-03-19 17:15:50 +0000 INFO [GitHosting] Running 'gl-setup' on the Gitolite install...
2014-03-19 17:15:51 +0000 WARN [GitHosting] Hook 'post-receive.git_multimail.py' is already present but it's not ours!
2014-03-19 17:15:51 +0000 INFO [GitHosting] Restoring 'post-receive.git_multimail.py' hook since forceInstallHook == true
2014-03-19 17:15:51 +0000 INFO [GitHosting] Installing hook '/data/dicet_napoli/servizi/redmine/plugins/redmine_git_hosting/contrib/hooks/post-receive.git_multimail.py' in '~/.gitolite/hooks/common/post-receive.d/git_multimail.py'
2014-03-19 17:15:52 +0000 INFO [GitHosting] Hook 'post-receive.git_multimail.py' installed
2014-03-19 17:15:52 +0000 INFO [GitHosting] Running 'gl-setup' on the Gitolite install...
2014-03-19 17:15:53 +0000 WARN [GitHosting] Hook 'post-receive.mail_notifications.py' is already present but it's not ours!
2014-03-19 17:15:53 +0000 INFO [GitHosting] Restoring 'post-receive.mail_notifications.py' hook since forceInstallHook == true
2014-03-19 17:15:53 +0000 INFO [GitHosting] Installing hook '/data/dicet_napoli/servizi/redmine/plugins/redmine_git_hosting/contrib/hooks/post-receive.mail_notifications.py' in '~/.gitolite/hooks/common/post-receive.d/mail_notifications'
2014-03-19 17:15:54 +0000 INFO [GitHosting] Hook 'post-receive.mail_notifications.py' installed
2014-03-19 17:15:54 +0000 INFO [GitHosting] Running 'gl-setup' on the Gitolite install...
2014-03-19 17:15:54 +0000 INFO [GitHosting] Installing Redmine Gitolite mirroring SSH keys ...
2014-03-19 17:15:57 +0000 INFO [GitHosting] Done !

This above it's a log about hooks that says that are already presents and it's the same everytime i reload the plugin admministration page (very slow).

I had repos in my project, before installing your plugins, but i can't see it anymore in the repository section of the project. These are the logs:

2014-03-19 16:53:57 +0000 ERROR [GitCache] repo_id is nil, exit!
2014-03-19 16:54:00 +0000 ERROR [GitCache] repo_id is nil, exit!
2014-03-19 16:54:18 +0000 ERROR [GitCache] repo_id is nil, exit!
2014-03-19 16:54:59 +0000 ERROR [GitCache] repo_id is nil, exit!
2014-03-19 16:57:04 +0000 ERROR [GitCache] repo_id is nil, exit!
smn-automation commented 10 years ago

I am having a similar problem... When I traverse to

https:///redmine/settings?tab=repositories

I see that the path for git cannot be resolved properly--it shows an orange circle with a white exclamation mark in it followed by the path

$REDMINE_HOME/plugins/redmine_git_hosting/bin/run_git_cmd_as_gitolite_user 

The setting for mercurial shows the correct path /opt/local/bin/hg and a green checkmark.

Interestingly, I don't have that path set in the $REDMINE_HOME/config/configuration.yml file, but instead have /opt/local/bin/git (like I do for Mercurial). Before installing the redmine_git_hosting plugin it rendered just fine.

I can easily run both opt/local/bin/git and $REDMINE_HOME/plugins/redmine_git_hosting/bin/run_git_cmd_as_gitolite_user while logged in as the redmine user and they work fine.

When traversing to

https:///redmine/admin/info

there isn't an entry for Git at all:

Environment:
  Redmine version                2.5.1.stable
  Ruby version                   1.9.3-p362 (2012-12-25) [x86_64-darwin10.8.0]
  Rails version                  3.2.18
  Environment                    production
  Database adapter               PostgreSQL
SCM:
  Subversion                     1.6.17
  Mercurial                      3.0
  Cvs                            1.12.13
  Filesystem                     
Redmine plugins:
  redmine_bootstrap_kit          0.1
  redmine_git_hosting            0.7.2
  redmine_sidekiq                2.0.0

Log file:

2014-05-15 14:30:17 -0700 ERROR [GitHosting] Problems to retrieve Gitolite hook parameters in Gitolite config
2014-05-15 14:30:17 -0700 INFO [GitHosting] Testing if Gitolite user 'git' can sudo to Redmine user 'redmine'...
2014-05-15 14:30:18 -0700 INFO [GitHosting] OK!
2014-05-15 14:30:18 -0700 INFO [GitHosting] Testing if Redmine user 'redmine' can sudo to Gitolite user 'git'...
2014-05-15 14:30:18 -0700 INFO [GitHosting] OK!
2014-05-15 14:30:18 -0700 ERROR [GitHosting] Problems to retrieve Gitolite hook parameters in Gitolite config
2014-05-15 14:30:18 -0700 INFO [GitHosting] Set Git hooks global parameter : redmineurl (http://localhost:3000/githooks/post-receive/redmine)
2014-05-15 14:30:18 -0700 ERROR [GitHosting] Error while setting Git hooks global parameter : redmineurl (http://localhost:3000/githooks/post-receive/redmine)
2014-05-15 14:30:18 -0700 INFO [GitHosting] Set Git hooks global parameter : debugmode (false)
2014-05-15 14:30:18 -0700 ERROR [GitHosting] Error while setting Git hooks global parameter : debugmode (false)
2014-05-15 14:30:18 -0700 INFO [GitHosting] Set Git hooks global parameter : asyncmode (false)
2014-05-15 14:30:18 -0700 ERROR [GitHosting] Error while setting Git hooks global parameter : asyncmode (false)
2014-05-15 14:30:18 -0700 INFO [GitHosting] Global hook directory '~/.gitolite/hooks/common/post-receive.d' is already present, will not touch it !
2014-05-15 14:30:19 -0700 INFO [GitHosting] Our 'post-receive.redmine_gitolite.rb' hook is already installed
2014-05-15 14:30:19 -0700 INFO [GitHosting] Our 'post-receive.git_multimail.py' hook is already installed
2014-05-15 14:30:19 -0700 INFO [GitHosting] Our 'post-receive.mail_notifications.py' hook is already installed
2014-05-15 14:30:19 -0700 INFO [GitHosting] Installing Redmine Gitolite mirroring SSH keys ...
2014-05-15 14:30:20 -0700 INFO [GitHosting] Done !

All green lines at

https://\/redmine/settings/plugin/redmine_git_hosting?tab=gitolite_config_test

except the ones pertaining to the hooks (similar errors as seen in the log).

I feel like I'm close to getting this all working, and I don't seem to have any public/private key sudo or other issues seen in similar issue posts, so I think I just need to get it to be happy with git being $REDMINE_HOME/plugins/redmine_git_hosting/bin/run_git_cmd_as_gitolite_user

Thank you

Scott

n-rodriguez commented 10 years ago

Interestingly, I don't have that path set in the $REDMINE_HOME/config/configuration.yml file, but instead have /opt/local/bin/git (like I do for Mercurial). Before installing the redmine_git_hosting plugin it rendered just fine.

It's normal. Actually the plugin override the default command to be $REDMINE_HOME/plugins/redmine_git_hosting/bin/run_git_cmd_as_gitolite_user. This way all commands are executed via sudo.

But Redmine cached this information the first time it is accessed. You should try to restart Redmine.

smn-automation commented 10 years ago

I had restarted Redmine several times, and even rebooted the server (it needed a sw update anyway). I also tried unchecking the git checkbox in settings, restarting, and then re-checking it, still no go. I also noticed at `https://\<redminehost\>/redmine/settings/plugin/redmine_git_hosting?tab=gitolite_config_test that the Git version line is blank. Anything else I should look at or try? I'm really looking forward to having Redmine and gitolite speak fluently!

n-rodriguez commented 10 years ago

I also noticed at `https:///redmine/settings/plugin/redmine_git_hosting?tab=gitolite_config_test that the Git version line is blank.

Here's the bug! (or around it)

n-rodriguez commented 10 years ago

Can you add this in plugins/redmine_git_hosting/lib/redmine_gitolite/hooks.rb line 319 logger.error { e.message } and restart Redmine?

Right after logger.error { "Error while setting Git hooks global parameter : #{name} (#{value})" }

smn-automation commented 10 years ago

Of course!

I'm not sure how helpful this is, it just says "Shell Error", but here's the new log:

2014-05-15 17:02:55 -0700 ERROR [GitHosting] Problems to retrieve Gitolite hook parameters in Gitolite config
2014-05-15 17:02:56 -0700 INFO [GitHosting] Testing if Gitolite user 'git' can sudo to Redmine user 'redmine'...
2014-05-15 17:02:56 -0700 INFO [GitHosting] OK!
2014-05-15 17:02:56 -0700 INFO [GitHosting] Testing if Redmine user 'redmine' can sudo to Gitolite user 'git'...
2014-05-15 17:02:56 -0700 INFO [GitHosting] OK!
2014-05-15 17:02:58 -0700 ERROR [GitHosting] Problems to retrieve Gitolite hook parameters in Gitolite config
2014-05-15 17:02:58 -0700 INFO [GitHosting] Set Git hooks global parameter : redmineurl (http://localhost:3000/githooks/post-receive/redmine)
2014-05-15 17:02:58 -0700 ERROR [GitHosting] Error while setting Git hooks global parameter : redmineurl (http://localhost:3000/githooks/post-receive/redmine)
2014-05-15 17:02:58 -0700 ERROR [GitHosting] Shell Error
2014-05-15 17:02:58 -0700 INFO [GitHosting] Set Git hooks global parameter : debugmode (false)
2014-05-15 17:02:58 -0700 ERROR [GitHosting] Error while setting Git hooks global parameter : debugmode (false)
2014-05-15 17:02:58 -0700 ERROR [GitHosting] Shell Error
2014-05-15 17:02:58 -0700 INFO [GitHosting] Set Git hooks global parameter : asyncmode (false)
2014-05-15 17:02:58 -0700 ERROR [GitHosting] Error while setting Git hooks global parameter : asyncmode (false)
2014-05-15 17:02:58 -0700 ERROR [GitHosting] Shell Error
2014-05-15 17:02:58 -0700 INFO [GitHosting] Global hook directory '~/.gitolite/hooks/common/post-receive.d' is already present, will not touch it !
2014-05-15 17:02:59 -0700 INFO [GitHosting] Our 'post-receive.redmine_gitolite.rb' hook is already installed
2014-05-15 17:02:59 -0700 INFO [GitHosting] Our 'post-receive.git_multimail.py' hook is already installed
2014-05-15 17:02:59 -0700 INFO [GitHosting] Our 'post-receive.mail_notifications.py' hook is already installed
2014-05-15 17:02:59 -0700 INFO [GitHosting] Installing Redmine Gitolite mirroring SSH keys ...
2014-05-15 17:03:00 -0700 INFO [GitHosting] Done !

The BASH config files seem to load just fine (your directions say to modify ~/.profile), but please let me know what else I can do to check, and thank you!

Scott

n-rodriguez commented 10 years ago

add logger.error { e.command } and logger.error { e.output }

smn-automation commented 10 years ago

Even though I can run $REDMINE_HOME/plugins/redmine_git_hosting/bin/run_git_cmd_as_gitolite_user as the redmine user from an interactive shell, doesn't look like it works from a non-interactive, so I'll look into that:

2014-05-15 17:08:33 -0700 ERROR [GitHosting] Problems to retrieve Gitolite hook parameters in Gitolite config
2014-05-15 17:08:33 -0700 INFO [GitHosting] Testing if Gitolite user 'git' can sudo to Redmine user 'redmine'...
2014-05-15 17:08:33 -0700 INFO [GitHosting] OK!
2014-05-15 17:08:33 -0700 INFO [GitHosting] Testing if Redmine user 'redmine' can sudo to Gitolite user 'git'...
2014-05-15 17:08:34 -0700 INFO [GitHosting] OK!
2014-05-15 17:08:35 -0700 ERROR [GitHosting] Problems to retrieve Gitolite hook parameters in Gitolite config
2014-05-15 17:08:35 -0700 INFO [GitHosting] Set Git hooks global parameter : redmineurl (http://localhost:3000/githooks/post-receive/redmine)
2014-05-15 17:08:35 -0700 ERROR [GitHosting] Error while setting Git hooks global parameter : redmineurl (http://localhost:3000/githooks/post-receive/redmine)
2014-05-15 17:08:35 -0700 ERROR [GitHosting] Shell Error
2014-05-15 17:08:35 -0700 ERROR [GitHosting] Command failed (return 127): $REDMINE_HOME/plugins/redmine_git_hosting/bin/run_git_cmd_as_gitolite_user config --global redminegitolite.redmineurl 'http://localhost:3000/githooks/post-receive/redmine' 2>&1
2014-05-15 17:08:35 -0700 ERROR [GitHosting] Command output : '-bash: git: command not found'
2014-05-15 17:08:35 -0700 INFO [GitHosting] Set Git hooks global parameter : debugmode (false)
2014-05-15 17:08:35 -0700 ERROR [GitHosting] Error while setting Git hooks global parameter : debugmode (false)
2014-05-15 17:08:35 -0700 ERROR [GitHosting] Shell Error
2014-05-15 17:08:35 -0700 ERROR [GitHosting] Command failed (return 127): $REDMINE_HOME/plugins/redmine_git_hosting/bin/run_git_cmd_as_gitolite_user config --global redminegitolite.debugmode 'false' 2>&1
2014-05-15 17:08:35 -0700 ERROR [GitHosting] Command output : '-bash: git: command not found'
2014-05-15 17:08:35 -0700 INFO [GitHosting] Set Git hooks global parameter : asyncmode (false)
2014-05-15 17:08:36 -0700 ERROR [GitHosting] Error while setting Git hooks global parameter : asyncmode (false)
2014-05-15 17:08:36 -0700 ERROR [GitHosting] Shell Error
2014-05-15 17:08:36 -0700 ERROR [GitHosting] Command failed (return 127): $REDMINE_HOME/plugins/redmine_git_hosting/bin/run_git_cmd_as_gitolite_user config --global redminegitolite.asyncmode 'false' 2>&1
2014-05-15 17:08:36 -0700 ERROR [GitHosting] Command output : '-bash: git: command not found'
2014-05-15 17:08:36 -0700 INFO [GitHosting] Global hook directory '~/.gitolite/hooks/common/post-receive.d' is already present, will not touch it !
2014-05-15 17:08:36 -0700 INFO [GitHosting] Our 'post-receive.redmine_gitolite.rb' hook is already installed
2014-05-15 17:08:36 -0700 INFO [GitHosting] Our 'post-receive.git_multimail.py' hook is already installed
2014-05-15 17:08:37 -0700 INFO [GitHosting] Our 'post-receive.mail_notifications.py' hook is already installed
2014-05-15 17:08:37 -0700 INFO [GitHosting] Installing Redmine Gitolite mirroring SSH keys ...
2014-05-15 17:08:38 -0700 INFO [GitHosting] Done !
n-rodriguez commented 10 years ago

Is git installed? apt-get install git-core

n-rodriguez commented 10 years ago

Also be sure that /opt/local/bin is in the PATH.

smn-automation commented 10 years ago

yes it is installed :-)

as git user:

bash-3.2$ whoami
git
bash-3.2$ git --version
git version 1.9.2
bash-3.2$ sudo -u redmine -i "$REDMINE_HOME/plugins/redmine_git_hosting/bin/run_git_cmd_as_gitolite_user --version"
git version 1.9.2
bash-3.2$ echo $PATH
~git/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

As redmine user:

bash-3.2$ whoami
redmine
bash-3.2$ git --version
git version 1.9.2
bash-3.2$ $REDMINE_HOME/plugins/redmine_git_hosting/bin/run_git_cmd_as_gitolite_user --version
git version 1.9.2
bash-3.2$ echo $PATH
~redmine/.rvm/gems/ruby-1.9.3-p362/bin:~redmine/.rvm/gems/ruby-1.9.3-p362@global/bin:~redmine/.rvm/rubies/ruby-1.9.3-p362/bin:~redmine/.rvm/bin:/opt/local/lib/postgresql84/bin:~redmine/.rvm/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

apt-get doesn't work so well on BSD or OSX ... ;-)

n-rodriguez commented 10 years ago

Maybe a bug in shell escaping...

smn-automation commented 10 years ago

Thanks to RVM I had already pulled out all spaces from all paths (that seems to be a sore point with the developer of RVM...) but I'll keep digging to see if I can find anything. Thank you again!

smn-automation commented 10 years ago

As I dig deeper, I'm looking in /plugins/redmine_git_hosting/lib/redmine_gitolite/config.rb and noticing that there is some code specific to versions of sudo earlier than 1.7.3

The version of sudo I'm currently using (Default install) is 1.7.0.

Since I'm almost positive this is something having to do with sudo / eval / $PATH, there may be a clue there...

smn-automation commented 10 years ago

So I can get more to work properly by replacing lines that look like this:

eval "git $cmd"

with this temporary kludge:

git $cmd

in $REDMINE_HOME/plugins/redmine_git_hosting/bin/run_git_cmd_as_gitolite_user (which I see is auto-generated by $REDMINE_HOME/plugins/redmine_git_hosting/lib/redmine_gitolite/config.rb)

I can't find the section of code that sets repository.class.scm_available referenced in plugins/redmine_git_hosting/app/views/repositories/_form.html.erb so the Git Version is still not showing up, and the Create repository button is still disabled...

smn-automation commented 10 years ago

Is there anything else I can check/do to track this down?

As mentioned earlier I got the hooks to install properly by modifying $REDMINE_HOME/plugins/redmine_git_hosting/bin/run_git_cmd_as_gitolite_user but I can't find the code that checks the "Git Version" at https://<RedmineHost>/redmine/settings/plugin/redmine_git_hosting?tab=gitolite_config_test or disables the "create" button at https://<RedmineHost>/redmine/projects/XXXXXXXXXXXXXXX/repositories/new

I would expect to see this error

scm: error during get version string: #{e.message}

based on the code in $REDMINE_HOME/app/models/repository.rb

but I don't see that in the log anywhere...

Thank you

smn-automation commented 10 years ago

I wonder if this applies:

http://mywiki.wooledge.org/BashFAQ/050 http://stackoverflow.com/questions/5253782/bash-problem-with-eval-variables-and-quotes

smn-automation commented 10 years ago

Short answer: problem solved, and as suspected NOT a Redmine or redmine_git_hosting problem...

Longer answer (for others who may run across this on OSX):

After following the good advice here at https://github.com/ericpaulbishop/redmine_git_hosting/issues/53 I was able to see what Redmine thinks my env is by adding these lines to $REDMINE_HOME/app/views/admin/index.html.erb

<%=h (%x[sudo -V]).chomp.strip %>
<br>
<%=h (%x[whoami]).chomp.strip %>
<br>
<%=h (%x[env]).chomp.strip %>
<br>

And it wasn't what I expected--indeed as predicted the PATH is wrong (it's missing any reference to places where git lives, specificaly /opt/local/bin in my environment on OSX).

So I did some digging, and saw the same problem with rvm env (it matched what I was seeing on the admin info page).

The problem is not with PATH not being correctly defined in the BASH setup files for the redmine or git users: it has to do with the setup for PATH for the the Apache www user!

And, for you Linux guys out there, you're going to LOVE this--"It was a Mac thing" :-P

This thread explains clearly how to add PATH components to the OS X version of Apache through OS X's launchd configuration: http://johnmccombs.inmap.net/2012/03/30/setting-path-for-apache-on-osx/

So after fixing that, and seeing the correct PATH on the Redmine Administrator Info page, I undid any previous exploratory kludges, and I can now create repositories from with Redmine!

Thank you again, I knew not to file any bugs :-)

n-rodriguez commented 10 years ago

And, for you Linux guys out there, you're going to LOVE this--"It was a Mac thing" :-P

^^ Maybe it will be helpfull for people running Apache + Passenger too :)