The problem: I have some configuration data (i.e., a small set of text files) that I need to keep synchronized across a number of different machines (running, at last count, at least three different operating systems).
It occurred to me this morning that Mercurial would be outstanding for something like this, since it doesn’t require a central server (thereby avoiding sysadmin entanglements) and can do its thing over ssh (a protocol already supported by the machines in question).
So I decided to run a little test.
I logged in to the iMac and cloned my bitbucket repository:
hg clone ssh://bitbucket.org/xxx/repo
running ssh bitbucket.org "hg -R xxx/repo serve --stdio"
destination directory: repo
requesting all changes
...
Then, on the WRI laptop, I tried to clone the repository on the iMac:
C:\Source>hg clone ssh://xxx@xxx.local/repo
Password: ...
remote: bash: hg: command not found
abort: no suitable response from remote hg!
Oops.
It seems a bit odd that I can ssh to the iMac and run hg, but not if I try to do both in one command. Clearly, there is some ssh-fu at work here I do not understand.
Fortunately, the Mercurial people have detailed & well-written documentation, answering this very question:
On the other hand, if the error message is remote: bash: line 1: hg: command not found, the problem is that the environment used by ssh does not have hg in its PATH. There are two ways to deal with this problem:
- In your ~/.hgrc file, set a remotecmd value in the [ui] section giving the exact path to hg.
- On the server, create a ~/.ssh/environment file that defines an appropriate PATH, and add PermitUserEnvironment yes to /etc/sshd_config.
I went with option #1. (On the WRI laptop, the file is named Mercurial.ini instead of .hgrc. I should probably fix that….)
C:\Source>hg clone ssh://xxx@xxx.local/repo
Password: xxx
destination directory: repo
requesting all changes
adding changesets
adding manifests
adding file changes
added 28 changesets with 114 changes to 49 files
updating to branch default
39 files updated, 0 files merged, 0 files removed, 0 files unresolved
remote: 28 changesets found
…and there was joy in Muddville.
(Except that Mercurial isn’t installed on all the machines that need to use it. So I am doomed to sysadmin entanglement after all.)