Install Mercurial on Linux (RHEL / CentOS)

By | August 13, 2014

Installing mercurial on Windows is straight forward, because there are installable packages (.msi / .exe ) readily available.
Installing on unix like systems is also easy altough there are different methods for different unix flavours. I had to spend some time figuring out how to install it on RHEL in offline (not connected to internet) mode.

Most reliable method I found is –

Install from the source

1. Download tarball (.tar.gz) from http://mercurial.selenic.com/release/?M=D
2. ftp/scp to Linux server
3. As root user – create an user to be used for mercurial.

/usr/sbin/useradd merc
passwd merc

cd /var/opt/software/
gzip -dc mercurial-3.1.tar.gz | tar xf –
chown merc:merc mercurial-3.1

mkdir /opt/mercurial/
chmod -R 777 /opt/mercurial

4. Install using setup.py script as ‘merc’ user.  Pre-Requisite is to have python installed (latest version – 2.7 worked well for me). RHEL/CentOS will generally have it pre-installed.

which python
cd /var/opt/software/mercurial-3.1
python setup.py install –force –home=/opt/mercurial

5. Verify
/opt/mercurial/bin/hg version
/opt/mercurial/bin/hg help

5. Login to all users who need to use Hg and it in their path (.profile / .bash_profile)
PATH=$PATH:/opt/mercurial/bin
export PATH

which hg
hg version
hg help