Hg: command not found

installationmercurial

I'm sure you guys are sick of questions of the "XX: Command not found" variety, so my apologies for adding another to the stack, but here it goes.

I'm trying to create a tarball of a compiled install of mercurial and python that i can send to various teams in my company who will then extract them on their isolated unix servers (all running the same version of the same os) and be running with hg even though their native python version is too old.

This actually has gone fine so far, but some machines are giving me trouble. When the tar ball is extracted the user will have a new bin folder which contains the hg and python executable files. After setting their PATH to that bin folder, the python executable works fine, but the hg executable yields a "hg: Command not found." error.

Could it be a bad path?

It gives the error if you call

> hg

despite the fact that

> which hg

yields the proper path to the hg executable

Plus, if you navigate to that folder and call

> ./hg

You still get "hg: Command not found."

The only way to get it to work is to call

> ./python hg

Which works properly and shows hg's help info.

Could it be a permission issue?

I did the extraction and all files are owned by me. I also verified the hg file and I have execute permissions as you'd expect.

Why am I getting that error?

Aside from path and permissions, I just don't know anything else to check. Any suggestions would be appreciated.

Thanks!

Best Answer

It could be something wrong with the magic line in the hg script. Try:

$ less `which hg`

The first line should be the absolute path to the python interpreter. Something like:

#!/usr/bin/python

(or wherever your python interpreter is). Double check that this path is correct.