Ruby Gem Location

Hi all  -

I am a bit new to Ruby and RubyMine so please bare with me...

I am using Ubuntu and have Ruby 1.8 and Ruby gems installed on my system. What I am trying to figure out is where my gems should install.
For example when I go to the attach gems dialog RubyMine installs my gems to /home/me/.gems directory.

But, if I go to command line and do a 'sudo gem install rake' for example it will install to /var/lib/gems. If I do not use 'sudo' they are put in /home/me/.gems.
So in order to be consistent what is the best place to keep these bad boys ???

Comment actions Permalink

Hello Carl,

Rubygems looks for gems in special gem pats, to see them execute in console

gem environmnet


Latest version of rubygems allow to install gems in local folder  ~/.gems. Both ~/.gems and /var/lib/gems folders are in gem paths. More over you can manually add some folder to gem paths. The only one difference that ~/.gems is visible only for current user. Actually we don't see any problem in using locally installed gems thus we decided not to request user password for sudo command.

Comment actions Permalink

Hi Roman;

I'm not sure I quite follow the logic that RubyMine is using when installing missing gems.

I'm working under OS X. I've used MacPorts to install Ruby 1.8 and RubyGems. These are installed to /opt/local/lib/ruby and /opt/local/lib/gem.
I have removed the default installation of Ruby that was part of Snow Leopard.

In my .profile, I have defined:
export PATH=/Users/tim/gems:$PATH
export GEM_HOME=/Users/tim/gems/1.8
export GEM_PATH=/Users/tim/gems/1.8

I have my .gemrc file set as follows:
gemhome: /Users/tim/gems/1.8
- /Users/tim/gems/1.8

This is the only location in which I have gems installed.

I built a project based on thoughtbot's Suspenders which includes a dependency on cucumber.

I have the cucumber gem installed (and it shows as attached), but when I run my project in RubyMine 2.0 Beta 3, it reports:
/opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:827:in `report_activate_error': Could not find RubyGem cucumber (>= 0) (Gem::LoadError)

At this point, where is RubyMine expecting to find cucumber?

When trying to debug, RubyMine reported it needed ruby-debug-ide. When accepting RubyMine's offer to install it, the following failure occured:
ERROR: Failed to build gem native extension.  /opt/local/bin/ruby mkrf_conf.rb WARNING:  Installing to ~/.gem since /opt/local/lib/ruby/gems/1.8 and       /opt/local/bin aren't both writable. WARNING:  You don't have /Users/tim/.gem/ruby/1.8/bin in your PATH,       gem executables will not run

Why would RubyMine install to ~/.gem when my GEM_HOME and GEM_PATH clearly point to a writable directly named /Users/tim/gems/1.8 ???

Aside from being new to Ruby on Rails and RubyMine, I am bewildered!


Comment actions Permalink


Try to launch RubyMine from console: for this in launch /Applications/RubyMine/Contents/MacOS/rubymine. All should work.

In my .profile, I have defined:
export PATH=/Users/tim/gems:$PATH
export GEM_HOME=/Users/tim/gems/1.8
export GEM_PATH=/Users/tim/gems/1.8

Unfortunately MacOS applies this .profile only for console. For all other applications MacOS provides some default environment which isn't affected by ~/.profile. Please read javascript:; and then you can correctly setup environment for or always launch it from console.


Please sign in to leave a comment.