2

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!

The Lame Duck
  • 197
  • 1
  • 8

1 Answers1

3

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.

Torian
  • 2,364
  • 18
  • 10
  • Thank you so much! You nailed it, the path was pointing to the original install path which would have worked on most, but not all, machines. You saved my day :) – The Lame Duck Sep 20 '11 at 02:08
  • 3
    In case you're wondering, you can do `#!/usr/bin/env python` so it'll work on multiple machines with multiple paths – Michael Lowman Sep 20 '11 at 02:18
  • 1
    the /usr/bin/env is great, but if you want to control a specific version,you will need to specify it directly. /usr/bin/env returns first in the path, and since @the lame duck is bringing his own version of python over it may or may not come first in the path. – Doon Sep 20 '11 at 02:31
  • Glad to help you :) – Torian Sep 20 '11 at 13:33