Error while cloning a remote Mercurial repository via ssh on OS X?

February 23, 2009

by — Posted in Code

While trying to set-up version control using Mercurial, I hit a snag trying to call hg commands over SSH to our OS X development server, that took up the better part of an afternoon. Having finally found the answer I’m recording it here in case I forget or to save anyone else similar suffering.

This is the what I was doing and the resulting error (note I’m using the default bash shell):

$ hg clone ssh://example@ remote: bash: hg: command not found abort: no suitable response from remote hg!

So, first of all find out where your hg command is located by running the following command while logged into the remote box:

$ which hg /usr/local/bin/hg

That gives us the path to the hg command so now we need to see what paths are available when logging into that remote box via SSH. To do so run the following command from the machine you are trying to access the remote box from (my MacBook in this case):

$ ssh example@ echo $PATH /usr/bin:/bin:/usr/sbin:/sbin

We can see that the “/usr/local/bin/” path to hg is not in there so moving back to the remote box create and/or open ~/.bashrc and add the following line:

export PATH="$PATH:/usr/local/bin"

Now back to my MacBook and run the previous command again:

$ ssh example@ echo $PATH /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

Great! Now we can see that “/usr/local/bin” is available and our original hg command now runs.