I'm trying to get Mercurial to serve using hgwebdir.cgi under Apache on Mac OS X Lion.
I followed the directions listed here: http://www.popitandrockit.com/2010/05/mercurial-server-on-osx-106-snow.html
That article is for Snow Leopard (I guess no one's tried to do this on Lion yet?) but it mostly works. I did make the modification that I did not use https because the machine in question is behind my company's firewall.
It says that I should be able to access a repository at http://servername/repository_name
but that doesn't work. I can, however, get a listing of them at http://servername/hg/
, where /hg
is the ScriptAlias
address. So I should be able to get to a repository via http://servername/hg/repository_name
, but instead I'm getting a nice Mercurial page telling me
An error has occured while processing your request:
repository /Users/username/Documents/repository_name not found
Well, the directory is valid and there is a valid repository there according to Mercurial (i.e., hg log
and similar commands don't error out)
On the main page I'm getting similar errors in Apache:
[(date)] [error] [client (ip address)] error accessing repository at /Users/username/Documents/repository_name
Were I to guess I'd say it was some sort of access or permissions issue but I'm not familiar enough with Apache or Mac OS X Lion to venture a guess as to how to fix it.
This indeed looks like a permissions problem. On a standard Mac OS X Apache install the web user and group are
_www
, and you need to make sure these have read and write access. Also Mercurial complains if the hgrc file’s permissions do not match the user. There are two ways to fix it:Make the repository owned by the Apache
_www
user. When you type:It should show
_www
_www
in the third and fourth column. If not, change the user of the directory:Note that if you change this, you should not access the repository on the file system from any other user, or else any newly created files will again have the wrong permissions.
Alternatively, explicitly add your user to the
trusted
section in yourhgweb.config
:In this case you still need to make sure that the
_www
user has access at all. If you type:It should show something like
drwxrwxr--
in the first column (the middlerw
are important) and_www
in the fourth. If the files are not readable or writable by the group, use the chmod command to make them:And you can change the group of your repository to
_www
like so:Which of the two is preferable depends on your situation: if you’re trying to host your repository on a server I would say the first is preferable, it is simpler and a little more secure. If you’re trying to host it on your local workstation for convenience, the second is easier, because then you can still access the repository from your current user.
Note that for ad-hoc sharing it may be easier to just run
hg serve
on the command line.I hope that helps.