Cloning a Mercurial repository over SSH
Solution 1
Sounds like hg
is not on your path. The Mercurial FAQ mentions possible fixes for this issue: FAQ/CommonProblems.
Add the remotecmd
value to your Mercurial configuration by opening ~/.hgrc
(or Mercurial.ini
on Windows) on your client machine and adding the following:
[ui]
remotecmd = /path/to/hg
where /path/to/hg
is the path to the hg
command on the remote server.
If you're having problems with your Mercurial configuration, you can use the hg showconfig --debug
command to obtain a full list of your Mercurial settings along with the path and line number of the configuration file that defines each configuration value.
Solution 2
You need a double // after hostname i.e.:
hg clone ssh://[email protected]//path/to/projectname projectname
Solution 3
Looks like mercurial isn't in your user's PATH
on the remote server.
Solution 4
On webfactional I had to add:
export PATH=$PATH:/home/<user>/bin
to .bashrc to get it to work. (also followed the remotecmd advice above)
Solution 5
You can use Sourcetree, TortoiseHg, Mercurial from the terminal, or any client you like to clone your Mercurial repository. These instructions show you how to clone your repository using Mercurial from the terminal.
- From the repository, click + in the global sidebar and select Clone this repository under Get to work.
- Copy the clone command (either the SSH format or the HTTPS). If you are using the SSH protocol, ensure your public key is in Bitbucket and loaded on the local system to which you are cloning.
- From a terminal window, change to the local directory where you want to clone your repository.
- Paste the command you copied from Bitbucket, for example:
CLONE OVER HTTPS:
$ hg clone https://[email protected]/teamsinspace/hg-documentation-tests
CLONE OVER SSH:
$ hg clone ssh://[email protected]/teamsinspace/hg-documentation-tests
If the clone was successful, a new sub-directory appears on your local drive.
This directory has the same name as the Bitbucket repository that you cloned.
The clone contains the files and metadata that Mercurial requires to maintain the changes you make to the source files.
Josh
Updated on July 05, 2022Comments
-
Josh almost 2 years
I'm having some difficulty cloning my mercurial repository over ssh.
Here's what I have tried:
hg clone ssh://[email protected]/path/to/projectname projectname
It's giving me this error:
remote: bash: hg: command not found abort: no suitable response from remote hg!
hg is installed on the server, however.
I was trying to follow the instructions on this website.
-
Josh over 13 yearsI followed these directions and added remotecmd = ~/bin/hg to the hgrc file in my project and in my home folder, however it doesnt seem to find that. Adding --remotecmd to the command given in the question works, however. How can I get it so I don't have to type it in every time
-
Richard Cook over 13 yearsPut it in your
.hgrc
configuration file in the[ui]
section. See comment in answer. -
Richard Cook over 13 yearsYou may have conflicts between your system-wide configuration, your user configuration and your project's configuration. Run
hg showconfig --debug
to see what your configuration is and where the values are derived from. -
Richard Cook over 13 yearsHave you tried setting
remotecmd
to the absolute path tohg
on your remote machine? -
Richard Cook over 13 yearsHmm. Do you set any default settings in the
[defaults]
section of any of your configuration files? It's possible that these might override/interfere with other configuration settings. Try removing any[defaults]
that might relate to theclone
command etc. and see if that makes any difference. However, it will most likely be easiest to change your bash profile on the remote system to ensure thathg
is on the path. -
Josh over 13 yearsI haven't touched the defaults. I tried to change the path in ~/.bash_profile from PATH=$PATH:$HOME/bin to PATH=$PATH:$HOME/bin:/home/jrs0390/bin and PATH=$PATH:$HOME/bin:/home/jrs0390/bin/hg but neither of those worked
-
Richard Cook over 13 yearsTry setting your path in
.bashrc
. Have you played with thePermitUserEnvironment
setting in yoursshd_config
file? This article (serverfault.com/questions/130834/…) discusses various settings and environment variables that might affect yourPATH
. -
Richard Cook over 13 yearsGlad we figured it out eventually!
-
CenterOrbit over 11 yearsremotecmd = /usr/local/bin/hg was the line I added to get my 'server' a Mac with mercurial to work with a pull request. Worked like a charm.
-
rohtakdev over 11 yearsadd [ui] remotecmd = /path/to/hg as well use above string for connection
-
Paolo over 11 yearsAdding
remotecmd
to a local.hgrc
fixed the path issue. However, in my particular setupremotecmd
introduced another error:remote: conq: invalid command syntax
. Just adding the PATH value to.bashrc
(on webfaction) was enough and really solved any issue for me. -
akauppi over 11 yearsI'm doing the same as CenterOrbit (= HomeBrew's location for hg). Likely the problem with @Josh back in 2010 has been the use of ~. Should use absolute path - it's pointing at a remote machine anyway.
-
gavenkoa over 10 yearsWhy it works only with double
//
for me? Is this documented? -
lwho over 10 years@gavenkoa: Because the first slash is not part of the path, but just the separator between host and path, so with one slash it's just a path relative to the user's home directory. The second slash makes it an absolute path.
-
lwho over 10 yearsFor one-off usage you can also give the remotecmd option on the command line instead of setting it permanently in .hgrc:
hg --config ui.remotecmd=/path/to/hg clone ...
-
Ryu_hayabusa almost 10 yearshg clone ssh://host://path-to-repo/ ... if you have a configured hostname in ~.ssh/config