Mac OS X applies .bash_profile and .profile only for Terminal.app environment and Apple's technical documentation suggests using ~/.MacOSX/environment.plist for other applications. So, by default PATH value will differ for RubyMine and the console.
We recommend to manage your environment variables using free Enviroment Variables preference pane instead of environment.plist manual editing.
Unfortunately, the "environment.plist" approach doesn't always work on MacOS < 10.6, e.g if you start RubyMine from Spotlight the environment is not applied.
Thus real solution is to set your environment variables in /etc/launchd.conf (thanks to David Goudreau for this tip). For detailed description please read Mac OS X Global Environment Variables article.
So you should:
1. Open /etc/launchd.conf file (e.g. $sudo nano /etc/launchd.conf)
2. Then set correct PATH env variable
setenv PATH /Users/romeo/.gem/ruby/1.8/bin:/opt/local/bin:/opt/local/sbin:/opt/local/libexec/git-core:/usr/local/mysql/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
3. Set other env variables for RubyMine if necessary
4. Save changes
5. Reboot
P.S: If you always launch RubyMine using Dock or QuickSilver and do not use Spotlight you can install Enviroment Variables preference pane and use it instead of the manual environment.plist editing.
NB: Please don't miss "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" in the end of PATH value, because PATH=...:$PATH doesn't work here.
As of MacOS 10.6, the ~/.MacOSX/environment.plist approach works fine for applications launched from Spotlight and it's not necessary to edit /etc/launchd.conf.
John, thank you, we've updated the documentation.
This appears to not be working for me. I'm running RubyMine 3.0.1 and Mac OS X 10.6.6. My Gemfile has a gem that requires a git repo clone. I've updated my environment vars as described above but when I try a "bundle install" from within RubyMine, I get the following error:
"sh: git: command not found"
Any ideas?
The preferences pane linked above is broken, pressing Save does nothing and it does not save your environment variables.
The preference pane works for me just fine on OSX 10.6.6. After adding the PATH key/value pair and clicking save, I can now see ~/.MacOSX/environment.plist which contains the PATH key/value pair I entered in the pref pane. Just in case someone doesn't know, the dot at the beginning of ".MacOSX" makes the folder hidden unless you go into terminal and type "ls -a" or "ls -al" to display hidden files/dirs.
Glad to hear the preferences pane works for you
Wish it worked for me
(i'm on 10.6.6 as well)
I have plenty of other RubyMine stuff that isn't working for me, so we probably balance each other out ![]()
Preference pane warns that changes will be applied after next login in MacOS. By the way run a simple script from RubyMine which outputs ENV["PATH"] - it will allow to check actual PATH env variable settings. The pref. pane works on my mac 10.6.6.
Check the ownership of ~/.MacOSX. If you don't own it, then you cannot write to
environment.plist unless you are logged in as the owner.
On my system, ~/.MacOSX was owned by root. Try the following from Terminal:
> sudo chown -RF 'yourUsername' ~/.MacOSX
@Basil: Are you using the Environment Variables system preference pane? I would think it would create the ~/.MacOSX folder correctly, no?
Yes, I am using Environment Variable Preference Pane 1.3 on a recent fresh installation of Mac OS X 10.6.6 and no, it obviously doesn't create the ~/.MacOSX folder correctly.
Yep, that did the trick! it was indeed owned by root. Once I chown'd it, the preference pane correctly writes the file.
Since with can't chain the PATH assignment (with PATH = ..., $PATH), how can we be sure that we don't erase values previously assigned to PATH?
Maybe /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" is not enough?!?
This all seems rather difficult. Why is there not a system setting within the app for the path? Not to mention, there are other dependencies such as RVM that cannot be set system wide.
Could you follow-up on this thread? This is a real problem, and the system settings option is not effective or practical.
The post http://stackoverflow.com/questions/135688/setting-environment-variables-in-os-x/3756686#3756686 seems to imply that "launchctl setenv PATH $PATH" in your profile should do the trick. Following that with "launchctl getenv PATH" does in fact show that it's updated. But when I run an irb console in RubyMine, I'm seeing some other path that I can't be sure where it's coming from.
The Environment Variable pane link doesn't work anymore. It can be found here: http://www.epikentros.net/Main/Mac_Software.html
I agree with Doug that this seems like it should be more of a priority and it's a little hard to comprehend why there's no "add to path" capability in Settings, but for myself I was able to work around this fairly easily. I will note that I'm on OS X 10.6.8, using RVM and Git via Homebrew. I found after much messing about that /usr/local/bin was not being added to PATH, and while none of the other methods worked for me (some gave really bizarre results which I won't bother to share), I was able to simply symlink git in /usr/bin and get back to work.
ln -s /usr/local/Cellar/git/1.7.6/bin/git /usr/bin/git
Hope that helps someone.
Anthony, sometimes the simplest solutions are the best. Helped me, thank you.
I do wish there were a way to view the path as RubyMine sees it, and to add to it. I wasn't really sure what to do with the Environment Variable Preference Pane.
On OS X 10.7.2 with RubyMine 3.2.4, the only thing we found to work was editing (or creating) /etc/launchd.conf as described above.
When setting the PATH environment variable using /etc/launchd.conf, be careful what value you use. We found that just using the PATH you see in Terminal had unintended consequences. To fix it, we had to remove /etc/launchd.conf, restart our machine, then run `launchctl getenv PATH`, and then use that value in /etc/launchd.conf, appending what we needed to it.
Setting variables in /etc/launchd.conf:
http://stackoverflow.com/questions/135688/setting-environment-variables-in-os-x
I have been looking for a way to do this without rebooting. Is there a way to rerun launchd.conf without rebooting?