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 had to set the env variable in /etc/launchd.conf for OSX 10.7.4. ~/.MacOSX/environment.plist had been working in 10.7.3.
really? is there no other way? i have homebrew with imagemagick and paperclip can't find identify (it works from the terminal, so the issue is clear) but i can't see why i have to fumble with a system wide file for various apps (launchd.conf) and set up env variables that point to my user folder's gem folder... this seems like a can of worms to me (plus it is a pretty ugly requirement in the first place).
As of 10.8 this technique no longer works. My git path is on the command line path and in the "Environment Variables" of System Preferences. Prior to 10.8, this worked just fine. Something apparently changed in Mountain Lion.
I also upgraded to 10.8. Git no longer worked, presumably my path was incorrect. I downloaded and reinstalled git. The instructions stated "This installs
/usr/local/git is a directory, use /usr/local/git/bin/git
It appears as though RubyMine local environment variables are working in RubyMine 4.5.2 on Mountain Lion. So, depending on the environment variable that you are trying to set and the usage context, this may be a nice alternative to setting it in launchd.conf or some other workaround. In my case, I set DYLD_LIBRARY_PATH as an environment variable under the Run/Debug configuration that I want it for.
The only way I could had my RubyMine working on my Mountain Lion was puting the
DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH under the Run/Debug config.As of MacOS 10.8,
~/.MacOSX/environment.plist is no longer supported. You have to change the application Info.plist instead. http://apple.stackexchange.com/questions/57385/
Changing Info.plist is not recommended, see http://stackoverflow.com/a/13588544/104891 . The easiest way is to run RubyMine from Terminal:
open -a /Applications/RubyMine.app/
In OS X 10.8 you cannot set the environment.plist , therefor Serge's sollution works best.
You can also set the PATH in your environment vars in RubyMine itself. I have written a little blog about it: http://stefanhendriks.wordpress.com/2012/12/27/os-x-10-8-mountain-lion-path-settings-not-picked-up-in-rubymine/
I have been looking for a way to do this without rebooting. Is there a way to rerun launchd.conf without rebooting?