kubitron / redmine_git_hosting

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

Repository content not shown in Redmine #87

Closed Arabus closed 12 years ago

Arabus commented 12 years ago

Hey, I've been rummaging through all the old tickets an quite a lot of google results but could find a solution so far, so I am down to asking you guys.

I have a debian/wheezy installation running with default system packages for Apache2 + passenger gitolite (v 2.3-1) ruby (v. 1.9.1) redmine (v 1.4.4) postgresql 9.1

I have done the setup in accordance with the readme adding a symlink from /usr/share/redmine/public/plugin_assets/readmine_git_hosting to /usr/share/redmine/vendor/plugins/redmine_git_hosting/assets and a

   chown www-data:www-data -R /usr/share/redmine

Unfortunately, when adding a new project to redmine, activating a git repository and following the initial instructions presented on the repository site I still do not get hte respository content displayed. Instead the repository site keeps informing me that the 'repository is empty' and that I should follow the instructions below... I am able to pull and clone from the repository though, I can create new files and push them with git. So the repository is created, and it dos work, but redmine refuses to show its content to me.

I have also enabled debug logging in Redmine and tried to make sense of the log output. Unfortunately I do not see any errors in there.

Can you provide me with guidance to further debug the problem or find a solution?

Output of script/about: Ruby version 1.9.3 (x86_64-linux) RubyGems version 1.8.23 Rack version 1.4 Rails version 2.3.14 Active Record version 2.3.14 Active Resource version 2.3.14 Action Mailer version 2.3.14 Active Support version 2.3.14 Edge Rails revision unknown Application root /usr/share/redmine Environment production Database adapter postgresql Database schema version 20120904060609

Thanks for your time already

kubitron commented 12 years ago

Can you give me the output of "./script/about"? Whose version of the plugin/which version are you running?

Do the following:

prompt% cd REDMINE_ROOT
prompt% export RAILS_ENV=production
prompt% ./script/about
Arabus commented 12 years ago

stupid me - sorry it was at the end of my shift and was thinking more of driving home :-/

I am currently using Redmine Git Hosting Plugin (v0.5.0x) as far as I can tell, cloned directly as in Step 5 of the Step-by-Step configuration instructions. The output of script/about is already attached to the issue above, I just forgot the part about the plugins :-/

About your application's environment
Ruby version              1.9.3 (x86_64-linux)
RubyGems version          1.8.23
Rack version              1.4
Rails version             2.3.14
Active Record version     2.3.14
Active Resource version   2.3.14
Action Mailer version     2.3.14
Active Support version    2.3.14
Edge Rails revision       unknown
Application root          /usr/share/redmine
Environment               production
Database adapter          postgresql
Database schema version   20120904060609
About your Redmine plugins
Redmine Git Hosting Plugin   0.5.0x

I also went through the production log a little more and found two invocations of the 'run_git_as_git_user' script, e.g.:

SELECT * FROM "git_caches" WHERE ("git_caches"."command" = '''/usr/share/redmine/vendor/plugins/redmine_git_hosting/bin/run_git_as_git_user'' ''--git-dir'' ''repositories/test478/sometestrepo.git'' ''-c'' ''core.quotepath=false'' ''-c'' ''log.decorate=no'' ''branch'' ''--no-color'' ''--verbose'' ''--no-abbrev''') LIMIT 1
SELECT * FROM "git_caches" WHERE ("git_caches"."command" = '''/usr/share/redmine/vendor/plugins/redmine_git_hosting/bin/run_git_as_git_user'' ''--git-dir'' ''repositories/test478/sometestrepo.git'' ''-c'' ''core.quotepath=false'' ''-c'' ''log.decorate=no'' ''ls-tree'' ''-l'' '':''') LIMIT 1

Which I guess are essentially for finding the revision and commit tree. Now while the first command (after the ''command'' =) does in fact provide some output, the second one does not, instead I get a

fatal: Not a valid object name :

In response. I am not sure If this is the cause of it though and if how to fix it.

kubitron commented 12 years ago

As a first debugging step, can you go to the plugin settings page and turn off caching?

See if that fixes things. If it does, there is a problem with your post-receive hook. If it doesn't, then there may be a problem with your sudoers setup.

Arabus commented 12 years ago

Thanks I will try that, tommorrow though.

Arabus commented 12 years ago

Thanks, disabling the cache seems to have done the trick. I tried fiddling around with the cache values, increasing the amount of entries etc. but to avail. Also setting the cache to 'until next commit' does not work. The repository is displayed as it was the last time it was fetched without caching.so indeed something seems to be broken here.

Now when you say there is a problem with the post-receive hook I assume you mean the ruby script in /home/gitolite/.gitolite/hooks/common/post-receive. Afaik it was put there by the redmine plugin at least according to its change date:

$ ls -la /home/gitolite/.gitolite/hooks/common/post-receive
-rwx------ 1 gitolite gitolite 3507 Oct 22 15:18 /home/gitolite/.gitolite/hooks/common/post-receive

Now I am not yet that fully immersed in using gitolite so I am struggling a little here. As far as I understood the post-receive hook there is a debug value that can be set per repository: hooks.redmine_gitolite.debug, which if set to true will cause the post-receive hook to print debug messages to stdout. My questing following that would be though, where does this log output go. Obviously it does not get sent to the client and I also could not find it in the .gitolite/log/ directory. So is there a different file where this goes or is this something I would have to configure?

kubitron commented 12 years ago

Hello. Ok, that is useful information.

The hook is installed by the plugin and shouldn't be touched. Three questions for you:

1) Is everything else working? Are the user keys getting installed properly properly? 2) How are you installing Ruby? In order for the post-receive hook to be executed, the git user must be able to execute Ruby scripts. 3) Is gitolite running on the same physical machine as redmine?

As for where the hook output goes, it is reflected back to git (the instance doing the push). You need make the hook run synchronously (in the settings page at the bottom), otherwise no output is generated.

kubitron commented 12 years ago

Also -- does setting the cache to timeout at (say) 1 minute work for you? (Should see updates that are more than a minute old).

kubitron commented 12 years ago

@arabus, ping! Wondering if you are still working on this problem? Love to figure out the issue and close it out.

Arabus commented 12 years ago

Sorry, was a bit busy the last few days.

About your questions;

  1. Yes the gitolite setup works fine. All repositories whether setup through redmine or not are accessible via ssh. All user keys uploaded via redmine are added successfully to the corresponding repository acls and work.
  2. I have installed Ruby via the package management of wheezy and afaik it is in the gitolite users path:
root@projects:~# su gitolite
gitolite@projects:~$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
gitolite@projects:~$ which ruby
/usr/bin/ruby
gitolite@projects:~$ ruby --version
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
  1. Yes gitolite is running on the same physical and logical machine because the readme states that this plugin setup does not yet support remote gitolite installations.

I have set the synchronous and debug options in the settings page for the plugin but still can not find any output neither in the gitolite logfile on the server, nor in the output of the pushing instance of the client.

EDIT: Forgot to actually save those configuration options -.- After disabling asynchronous hooks and enabling the debug I got the following output on the git client side:

Notifying ChiliProject/Redmine project test478 about changes to this repo.
..
Error contacting ChiliProject/Redmine about changes to this repo.

I guess this is where I will continue my debugging...

Arabus commented 12 years ago

Ok enabling the cache with a delay of 1 minute somehow seems to work, despite the error message. At least I do see the last commit in the repository page now.

Arabus commented 12 years ago

So after some fiddling with the log method in the post-receive hook and uncommenting the line

log("HTTP_ERROR:" + e.to_s, true, true)

I got some hint as to why something went wrong through the debug output: "HTTP_ERROR:can't convert Fixnum into String"

So after finding out that this exception seems to be thrown when the 'set_form_data' method is called I suspected my ruby libraries and did a gem update. After that the Error switched to: "HTTP_ERROR:invalid value for Integer(): ":""

Some more debugging later it seems that this error is thrown when the 'set_form_data' method uses the params.map method and the following block is called on the 'projectid=>test478' value pair. I tried using the log method at the stat of the block just after { |k,v| but the exception is thrown before either key or value could be printed.

Maybe you have an idea?

EDIT: Appears that when using ruby1.8 the hook works just fine. So this is just an issue of using ruby 1.9 :-/ I wonder if one can make this version independent

EDIT2: Seems there is a method in Ruby1.9 called 'URI::encode_www_form(enum)' that does exactly what you want. A version aware script would be the first dirty hack coming to mind but I guess there are more elegant ways?

kubitron commented 12 years ago

Ok. This is helpful. Sorry about the problems. Been having a bunch of subtle 1.9 bugs... Let me look for a moment.

kubitron commented 12 years ago

Ok. @Arabus , try pulling from master to see if this fixes your problem. It turns out that 1.8 vs 1.9 changed (pretty drastically) what it means to index a string as an array... Sigh.

I think that I have a simple fix that works for both 1.8 and 1.9.

Arabus commented 12 years ago

Works like a charm. thanks a lot for your time and help :)

kubitron commented 12 years ago

Ok. Thanks for tracing it down. It wasn't quite what you thought, but close.

I'm going to close out this bug. If you see another problem, please register a new issue.