Mercurial - 404 Error When Accessing Repository
Added by Dustin B over 13 years ago
Hopefully this is a quick fix for those with experience!
I just finished up installing Mercurial and Redmine on my shared hostgator server to the tee from Redmine and Mercurial documentation, but have run in to a small problem. Mercurial works pefectly, I was able to create a repo, clone it, and sync to it without any issues, except when I add the repo to Redmine and go to the repository tab, I get a 404 error. I made sure to double check that I set the directory beginning from the root and it didn't work. I tried multiple different kinds of ways of writing out the directory but still No luck. I ended up opening my production.log, and this is the entry written every time I get the 404 error.
Processing RepositoriesController#show (for 74.56.***.*** at 2012-01-10 13:59:43) [GET]
Parameters: {"action"=>"show", "id"=>"testhg1", "controller"=>"repositories"}
hg: error during getting info: hg exited with non-zero status: 255
hg: error during getting info: hg exited with non-zero status: 255
Rendering template within layouts/base
Rendering common/error (404)
Completed in 280ms (View: 12, DB: 2) | 404 Not Found [http://redmine.mydomain.org/projects/testhg1/repository]
Any help on this would be greatly appreciated! Thank you!
Replies (2)
RE: Mercurial - 404 Error When Accessing Repository
-
Added by Jeff Jason II about 13 years ago
Bump - same error here after upgrading from 1.2.x to 1.3.2
RE: Mercurial - 404 Error When Accessing Repository
-
Added by Jeff Jason II about 13 years ago
Went into development mode to get some better logging:
Processing RepositoriesController#show (for ***.***.***.*** at 2012-03-15 22:54:47) [GET] Parameters: {"action"=>"show", "id"=>"go", "controller"=>"repositories"} Setting Columns (0.9ms) SHOW FIELDS FROM `settings` SQL (0.1ms) SELECT max(`settings`.updated_on) AS max_updated_on FROM `settings` User Columns (1.0ms) SHOW FIELDS FROM `users` User Load (0.1ms) SELECT * FROM `users` WHERE (`users`.`id` = 3) AND (users.status = 1) AND ( (`users`.`type` = 'User' OR `users`.`type` = 'AnonymousUser' ) ) Project Columns (0.8ms) SHOW FIELDS FROM `projects` Project Load (0.1ms) SELECT * FROM `projects` WHERE (`projects`.`identifier` = 'go') LIMIT 1 Repository Load (0.1ms) SELECT * FROM `repositories` WHERE (`repositories`.project_id = 2) LIMIT 1 Repository Columns (0.7ms) SHOW FIELDS FROM `repositories` EnabledModule Load (0.2ms) SELECT name FROM `enabled_modules` WHERE (`enabled_modules`.project_id = 2) EnabledModule Columns (0.7ms) SHOW FIELDS FROM `enabled_modules` Setting Load (0.1ms) SELECT * FROM `settings` WHERE (`settings`.`name` = 'autofetch_changesets') LIMIT 1 Repository::Mercurial Columns (0.7ms) SHOW FIELDS FROM `repositories` Shelling out: '/usr/bin/hg' '-R' '/var/lib/hg/godc' '--encoding' 'utf-8' '--config' 'extensions.redminehelper=/var/www/corp/redmine/lib/redmine/scm/adapters/mercurial/redminehelper.py' '--config' 'diff.git=false' 'rhsummary' hg: error during getting info: hg exited with non-zero status: 255 Shelling out: '/usr/bin/hg' '-R' '/var/lib/hg/godc' '--encoding' 'utf-8' '--config' 'extensions.redminehelper=/var/www/corp/redmine/lib/redmine/scm/adapters/mercurial/redminehelper.py' '--config' 'diff.git=false' 'rhmanifest' '-r' 'tip' '' Rendering template within layouts/base Rendering common/error (404)
so the error seems to be with this command:
'/usr/bin/hg' '-R' '/var/lib/hg/godc' '--encoding' 'utf-8' '--config' 'extensions.redminehelper=/var/www/corp/redmine/lib/redmine/scm/adapters/mercurial/redminehelper.py' '--config' 'diff.git=false' 'rhsummary'
which works fine when I run is as root
root@redacted:/var/www/corp/redmine# '/usr/bin/hg' '-R' '/var/lib/hg/godc' '--encoding' 'utf-8' '--config' 'extensions.redminehelper=/var/www/corp/redmine/lib/redmine/scm/adapters/mercurial/redminehelper.py' '--config' 'diff.git=false' 'rhsummary' <?xml version="1.0"?> <rhsummary> <repository root="/var/lib/hg/godc"> <tip revision="426" node="4fbdff1fbd79"/> <branch revision="426" node="4fbdff1fbd79" name="default"/> </repository> </rhsummary>
but my webserver runs as www-data which doesn't have access to the hg dir
root@redacted:/var/www/corp/redmine# sudo su - www-data $ '/usr/bin/hg' '-R' '/var/lib/hg/godc' '--encoding' 'utf-8' '--config' 'extensions.redminehelper=/var/www/corp/redmine/lib/redmine/scm/adapters/mercurial/redminehelper.py' '--config' 'diff.git=false' 'rhsummary' abort: repository /var/lib/hg/godc not found! $ ls -l /var/lib/hg ls: cannot open directory /var/lib/hg: Permission denied $
give my www-data user access to the repo and the command now works:
$ groups www-data hg $ '/usr/bin/hg' '-R' '/var/lib/hg/godc' '--encoding' 'utf-8' '--config' 'extensions.redminehelper=/var/www/corp/redmine/lib/redmine/scm/adapters/mercurial/redminehelper.py' '--config' 'diff.git=false' 'rhsummary' <?xml version="1.0"?> <rhsummary> <repository root="/var/lib/hg/godc"> <tip revision="426" node="4fbdff1fbd79"/> <branch revision="426" node="4fbdff1fbd79" name="default"/> </repository> </rhsummary> $
Tested it on redmine and still got the error but when I restarted apache everything was as it should be.
(I'm using phusion passenger.)
The upgrade turned out to be a red herring, the actual thing that caused this was the change from running with script/server as my user (which had repo access) to running as a properly installed phusion passenger production instance.