When trying to start your Ruby application from within RubyMine using a “Run” or “Debug” configuration, you get an error message like this:
/usr/share/ruby-rvm/rubies/ruby-1.9.2-p180/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /usr/share/ruby-rvm/gems/ruby-1.9.2-p180/bin/unicorn_rails -l 0.0.0.0:5000 -E development -c ./config/unicorn.rb
/usr/share/ruby-rvm/gems/ruby-1.9.2-p180/gems/bundler-1.1.3/lib/bundler/spec_set.rb:90:in `block in materialize’: Could not find rake-0.9.2.2 in any of the sources (Bundler::GemNotFound)
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p180/gems/bundler-1.1.3/lib/bundler/spec_set.rb:83:in `map!’
Process finished with exit code 1
This happens because RubyMine itself does not run within a RVM environment, so cannot start Ruby applications correctly from it. You probably have installed RVM globally (like from the Ubuntu package) and all your gems of RVM environments are likewise stored globally rather than in ~/.rvm/. However, RubyMine is only able to automatically detect and use RVM environments when these are stored in ~/.rvm/ [source]. So in our case here, the applications try to use globally installed gems, which are not necessarily there.
This can be fixed by starting RubyMine from a login shell where RVM is loaded (such as a virtual terminal; check with “type rvm | head -1” and “which ruby” if RVM is loaded and your desired RVM environment is in use first).
This can also be worked around by not starting applications from within RubyMine at all, instead using a login shell for that.
The more elegant solution is to use the fact that RubyMine can use RVM environments if the gems are found in ~/.rvm/. For that either uninstall RVM and re-install it locally into ~/.rvm/, which is the simplest and most comfortable way [instructions]. Alternatively, transform your system-wide install into a “mixed mode” installation, where RVM is installed system-wide but the gems and rubies reside in ~/.rvm/ [instructions].