views:

125

answers:

1

I'm having difficulty figuring out how to clone my Mercurial repository from my local machine to the server. I actually found an answer to my question here (As the second part of #4.5 in http://mercurial.selenic.com/wiki/FAQ), but I don't know what to do with the answer.

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 would like a clearer explanation of how to solve this problem BOTH ways. How does one find out the exact path of their Mercurial installation? What is an "appropriate PATH" to use on the server?

+2  A: 

How does one find out the exact path of their Mercurial installation?

Log on to the server and run command -v hg. The response is the full path to hg that would be run given your current environment. Now that you know the full path, you can easily use the remotecmd option in your ~/.hgrc.

What is an "appropriate PATH" to use on the server?

The most basic PATH that a user should have is /usr/bin:/bin (although /usr/local/bin:/usr/bin:/bin is also common). The appropriate PATH for your situation is whatever your current $PATH is plus the directory that contains the hg binary, as determined above -- /usr/bin:/bin:/path/to/hg/dir.

jamessan
Logging on to the remote server gives you an interactive shell whereas mercurial is getting a non-interactive shell, and they hit different configuration files (.bashrc vs. .bash_profile),Starting with the (non-interactive) command: 'ssh user@remote echo '$PATH' is worth doing too.
Ry4an
I did both things as described, and still had difficulty, so I ended up just using FTP. I don't know if the problem was on my end, in the Mercurial FAQ or in your answer. Since your answer has some useful things in it that did work, I'm going to accept it, despite not solving my problem.
JayWilmont