Project

General

Profile

There's no browse panel in repository

Added by Daniel Chong over 15 years ago

Hi,

I just started using Redmine, and wanted to link a repository to it. It's using Mercurial, I have v1.0.2 installed. I had some problem with it initially but it works after I run
  • ruby script/runner "Repository.fetch_changesets" -e production

But I can't seem to browse the source code, I can only see the change log. Is there another set of command I need to run??

I've tried:
  • refresh the page many times
  • restarted Passenger by placing "restart.txt" in the tmp folder
  • tried using other browser

help?

Thanks


Replies (6)

RE: There's no browse panel in repository - Added by Brian DeVries over 15 years ago

I had this exact same problem. I'm running Redmine (frequently updated from the svn repository) with Mercurial (1.0.2) on a Dreamhost server. I could see the revisions, but whenever I tried clicking on one, it wouldn't let me display the files either.

I tried asking on IRC and searching this site, but didn't find much help, so I finally decided to dig through the code to figure out what the problem was. I wound up having to change the following two things in my setup.

The first problem was the PYTHONPATH environment variable. I compiled and installed Mercurial locally on my Dreamhost account, so I had manually set the PYTHONPATH variable in my .zshrc, so Mercurial could find its libraries. However, because I had not set it in the Redmine / RoR environment, running the hg command would raise an ImportError because it couldn't find the libraries it needed. I added the following line to my config/environment.rb:
ENV['PYTHONPATH'] = '/path/to/libs

This now allowed Mercurial to run correctly (as determined from logging debugging information). However, I was still unable to see my files. The problem here was my repository URL. I had chosen a file:///home/me/blah form for the URL, rather than using the fully qualified path (/home/me/blah). I changed the entry in the repositories table to have the directory name rather than the URL. After making these two changes, I am now able to see the directory listing, view my files, perform diffs, etc.
  • For some commands, using file:///blah URLs work (mainly those run via hg -R file:///blah). However, options like --cwd would not recognize the URL form, only the pathname form. I didn't see an easy way of making such a change to the source code (i.e., to use the URL for the -R option and use the pathname for the --cwd and other options), so I just went ahead and changed the repository URL.

As a side note, for non-Rails users who are attempting to debug their problems (assuming you know Ruby, just not RoR), the trick is setting config.log_level = :debug in your environment.rb file, then using logging.debug 'a debug msg' in your code to essentially do output-based debugging.

I would like to suggest a patch to the code to check whether the hg command works properly, perhaps when the repository is set, so that problems like this are flagged early and the User can know to update their environment.rb accordingly. Also, the major difficulty with these was the silent failure - no text was displayed on the web page and no error messages were written to the log file, even when config.log_level = :debug was set in my environment.rb. This has taken a very large amount of time to fix, mainly because the feedback I received from Redmine was practically nonexistent. I realize that both of these are dumb mistakes, but having some sort of feedback as to the cause of the error would be very beneficial (i.e., it would only take 5 minutes for me to say "ack, I'm an idiot" vs. ~15 hours).

So for a tl;dr:
  1. You must make sure that the PYTHONPATH environment variable has been set to include the Mercurial libraries, by setting ENV['PYTHONPATH'] = "/path/to/libs" in config/environment.rb
  2. Assuming you're working on a local machine, you must set the repository path to the filesystem pathname (/home/me/blah), rather than using a file:///home/me/blah URL-style pathname.

I'd be very curious to know whether there is a better way to do it than this; this is simply what I've found that works, so I figured I'd post it here. If it's on-target, would it be possible to add this to the Wiki, since both of these (especially the last one, since Redmine takes file:///home/me/blah pathnames as legitimate, but Mercurial doesn't work with them it seems) are not completely obvious and are quite easy to miss, especially for someone who's never touched Ruby on Rails before?

RE: There's no browse panel in repository - Added by Tine Šukljan over 15 years ago

Hi. I actually have the same problem. But don't really understand you solution. I have redmine (0.7.3) and Mercurial (0.9.5) installed on Ubuntu. Mercurial installed from apt.

In the repository view I see only the revisions. But nothing changes even if I put the ENV in the environment.rb. It is probably because I put the wrong path in it. I don't know to wich library should the libs point out. Could you explain this better?

Thank you.

RE: There's no browse panel in repository - Added by Brian DeVries over 15 years ago

Tine:

Well, if you installed Mercurial through apt, then my offhand expectation would be that the libraries are in the default paths and soforth. You should be able to type which hg at the command-line and get /usr/bin/hg as the result. Executing hg by itself should print out the standard information message. Also, you should also be able to type echo $PYTHONPATH at the command-line and receive a blank result. If all of these are the case, then I would think the problem is not RoR's inability to find the Mercurial executable or its Python libs.

Assuming that Mercurial is in a standard location, then you can also check whether RoR can find it. I believe RoR will run as the user for your web server (apache maybe?), so if you can, log in as that user and attempt to execute the hg command, and see what happens.

If everything looks good on the Mercurial end, then the next step is to check your repository location. What (generally) is the repository URL? Does it look like http://something.com/hg, or file:///path/to/my/repos, or /path/to/my/repos? The only one I know of working is the last one - a direct path to the repository location. I know file:/// doesn't work, and I have my doubts about http://, though I haven't really tried it.

Beyond that, not entirely sure what the problem is. I would suggest taking the following steps to get more information (note that I'm running the latest svn of Redmine, so your files may vary slightly):
  1. In config/environment.rb, set config.log_level = :debug. This will enable debugging messages to be output to the log file, available in the log directory.
  2. Restart Redmine (in the main Redmine directory, type touch tmp/restart.txt)
  3. Attempt to navigate to the project repository. Then, check the log file. It should have lines saying Shelling out: hg -R '/path/to/my/repos' --cwd '/path/to/my/repos locate -r tip. Try running this command yourself, preferably with your web server user, to make sure it works.
  4. Beyond that, you can try debugging the app yourself. The main file you're interested in is lib/redmine/scm/adapters/mercurial_adapter.rb (specifically the entries function) and lib/redmine/scm/adapters/abstract_adapter.rb. Just start tossing in logging statements, like logger.debug "This variable = " + var.to_s, and checking your log file. Remember to restart Redmine whenever you change something, even if it's just adding logging statements.

Beyond that, I'm not sure what the problem is. The main things I found were the environment variables and the repository URL. Since you installed everything in a standard location, the env vars shouldn't be a problem; double-check to make sure, since it's not out of the question, but that wouldn't be what I expect is causing the problem. This means that if your repository is hosted on the same machine as Redmine, and you're accessing it directly on the file system (not via file:///), then I don't know what else the issue could be offhand, so you'll have to do some debugging yourself.

Hope this helps!

RE: There's no browse panel in repository - Added by Tine Šukljan over 15 years ago

I looked at the trunk version and there was many differences in those files you mentioned..So I installed the trunk version and everything works fine now. Seems that everything is fine in the trunk version for me.

RE: There's no browse panel in repository - Added by John Vandervort about 15 years ago

NOTE: I had to add a both:

ENV['PYTHONPATH'] = '/home/youraccount/lib/python'
ENV['PATH'] = "#{ENV['PATH']}:/home/youraccount/bin"

to get it work work in my shared environment. The debug messages didn't really help. Just a 500 server error.
It would have been so nice to see something like: "can't find hg" from rails:)

PS: I'm a newbie to rails, so there may be a better place for this path tweak.

Hope it helps someone.

RE: There's no browse panel in repository - Added by Mikel Azkolain almost 15 years ago

Thanks for the fix John.

I also had the same issue, but on a dreamhost account.

It seems that the system-wide installation of mercurial is somewhat buggy and it was taking precedence over the local mercurial install.

In my case the solution was to place the local path component before the rest of the variable, and it worked.

ENV['PATH'] = "/home/account/bin:#{ENV['PATH']}" 
    (1-6/6)