hg: command not found

5,638

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.

Share:
5,638

Related videos on Youtube

The Lame Duck
Author by

The Lame Duck

Senior .Net Software Engineer and Developer and Founder of PlayAlongPiano.com

Updated on September 18, 2022

Comments

  • The Lame Duck
    The Lame Duck almost 2 years

    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
    The Lame Duck almost 13 years
    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 :)
  • Michael Lowman
    Michael Lowman almost 13 years
    In case you're wondering, you can do #!/usr/bin/env python so it'll work on multiple machines with multiple paths
  • Doon
    Doon almost 13 years
    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.
  • Torian
    Torian almost 13 years
    Glad to help you :)