"/usr/local/bin/hg doesn't appear to be a valid hg executable"

I'm using mercurial for a project, but PyCharm can't seem to find the right hg executable.  According to "which hg" my hg executable is located at "/usr/local/bin/hg", but PyCharm says its not valid.  Any suggestions on how to configure this correctly?  Thanks.

8 comments

Снимок экрана 2010-09-09 в 12.56.29.png

Michael, is this the dialog message you see?

Did you try to locate your hg executable file using the browse button in the right? (or you just tried entering the path by hands)

Anyway, here is the mechanism we use to identify whether the given file is hg executable:

1. It's name is 'hg'.

2. 'hg version' command quits without errors and returns a non-empty output (information about the current version actually).

Could you please check if your hg satisfies these conditions?



Attachment(s):
%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA %D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0 2010-09-09 %D0%B2 12.56.29.png
0

Hi Kirill,

Thanks for your reply.  That is indeed the error message I am seeing.  I tried browsing to the executable like you suggested, but it still gave the same error.  Here's a screenshot of the error message this time:

Screen shot 2010-09-09 at 6.59.34 AM.png

I'm pretty certain that's the correct executable since "which hg" also points to that file. 

Also, "hg version" gives this output:

Mercurial Distributed SCM (version 1.5)

Copyright (C) 2005-2010 Matt Mackall <mpm@selenic.com> and others

This is free software; see the source for copying conditions. There is NO

warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I'm not sure if this is helpful, but I followed this article when I originally installed mercurial: http://hivelogic.com/articles/compiling-mercurial-on-snow-leopard

Let me know if there's anything else I should try.  Thanks for your help.



Attachment(s):
Screen shot 2010-09-09 at 6.59.34 AM.png
0

Michael,

It seems that there are some specific preferences (environment variables most likely) defined in your shell (in ~/.profile probably). They are applied when you run hg from the shell, but they are not visible from PyCharm.

Because of that executing hg fails without these variables defined, which leads to the error you've seen.

To set the environment variables in such a way that will be seen both by your shell and by PyCharm, please define them in the environment.plist file: http://developer.apple.com/library/mac/#qa/qa2001/qa1067.html

Or if you don't like to set the variables globally you may start PyCharm from a shell script and define the variables in that script. 

Anyway, may I see your configuration file please to check which configuration may be used by PyCharm users?

0

Sorry it took me so long to get back to you about this.  After looking over my ~/.profile, this is the only line that seemed relevant:

export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/local/pgsql/bin:/Users/godshall/.gem/ruby/1.8/bin:$PATH"

Also, the article you linked is from 2001...are you sure it is still applicable to OSX 10.6?  Thanks for your help.

0

Yep, the article is still applicable for 10.6: you're able to define "public" environment variables, including PATH, by declaring them in ~/.MacOSX/environment.plist

Note that you may need to create the file (I didn't have it by default):

mkdir ~/.MacOSX

cd ~/.MacOSX

touch environment.plist

open environment.plist

It will open the Property List Editor application. You may declare new variables there, and you also may use current value as usual, for example: $PATH

To check my assumption that the cause of the error is missing configuration variables in IDEA which exist in your shell, could you please do one of the following actions (better both, but not simultaneously :-) ):

1. define your PATH in environment.plist and restart IDEA - this should help to resolve your problem.

OR

2. Temporarily disable all your .profile file (rename it for example) and try to execute /usr/local/bin/hg from Terminal - this should fail.

Thanks.

0

Ok, here are the results from those tests:

1. I created ~/.MacOSX/environment.plist as you instructed, and tried several different values for PATH, but nothing has worked so far.  Here's a screenshot of the values I entered for PATH in environment.plist:

Screen shot 2010-09-23 at 3.11.13 PM.png

I restarted PyCharm each time I changed the value, but got the same error every time.  I may not be entering the values correctly, so let me know if I need to use a different syntax.

2. You are correct that after renaming ~/.profile, the "hg" command no longer works in terminal.  I'm not sure if this is helpful, but here's the error it gave me:

abort: couldn't find mercurial libraries in [/usr/local/bin /Library/Python/2.6/site-packages/pip-0.6.3.post1-py2.6.egg /Library/Python/2.6/site-packages/virtualenv-1.4.5.post1-py2.6.egg /Library/Python/2.6/site-packages/virtualenvwrapper-1.24-py2.6.egg /Library/Python/2.6/site-packages/setuptools-0.6c11-py2.6.egg /Library/Python/2.6/site-packages/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg /Library/Python/2.6/site-packages/fez.djangoskel-0.3.1-py2.6.egg /Library/Python/2.6/site-packages/Cheetah-2.4.1-py2.6-macosx-10.6-universal.egg /Library/Python/2.6/site-packages/PasteScript-1.7.3-py2.6.egg /Library/Python/2.6/site-packages/Markdown-2.0.3-py2.6.egg /Library/Python/2.6/site-packages/PasteDeploy-1.3.3-py2.6.egg /Library/Python/2.6/site-packages/Paste-1.7.2-py2.6.egg /Library/Python/2.6/site-packages/pycrypto-2.0.1-py2.6-macosx-10.6-universal.egg /Users/godshall/src/django-startproject /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6 /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload /Library/Python/2.6/site-packages /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/wx-2.8-mac-unicode]

(check your install and PYTHONPATH)

Thanks for helping me figure this out!



Attachment(s):
Screen shot 2010-09-23 at 3.11.13 PM.png
0

So, according to the result of the second test we've recovered that the problem really is with some specific environment you have set in .profile.

We're moving forward indeed, hope will solve the problem soon.

Your screenshot looks fine.

But note that after you make changes in environment.plist you have to relogin the system so that it applies new values for environment variables. Did you do it?

Also, let's see that your changes really apply:

1. Set up a new variable in environment.plist. Something new which you don't have defined anywhere, like MY_TEST_VARIABLE. Assign any value to it.

2. Relogin.

3. Open Terminal and check if the value was assigned: echo $MY_TEST_VARIABLE should return value you've set in environment.plist.

If that works, test the PATH variable then:

1. comment definition of PATH in .profile

2. repeat the steps above - but for real PATH variable and real value.

3. When you see that PATH is correctly visible by Terminal.app, though you didn't define it in .profile, it means that environment.plist settings were applied successfully.

4. Then you may start IDEA and check if it finds Mercurial.

If everything succeedes, except step 4, then could you please provide the whole content of your .profile file here? Maybe it is not only the PATH variable.

0

I've filed a YouTrack issue as a proposed solution for this problem: http://youtrack.jetbrains.net/issue/IDEA-59345

0

Please sign in to leave a comment.