Search code examples
rubyruby-on-rails-4bundlerrubymine-7

RubyMine is not installing gems to the right directory


I have encountered a problem where I create a ruby-on-rails application using RubyMine v7.0 and when I go to run, I get prompted with

C:/ruby-2.0.0-p643-x64-mingw32/lib/ruby/gems/2.0.0/gems/bundler-1.9.1/lib/bundler/spec_set.rb:92:in `block in materialize': Could not find json-1.8.2 in any of the sources (Bundler::GemNotFound)

and when I run

gem install 'json'

it succeeds but gives the same error even when I run the app again, even after running 'bundle install'.

when I use bundle show 'json' it shows the gem location to be

C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/json-1.8.2

which is different from the location RubyMine is looking in

C:/ruby-2.0.0-p643-x64-mingw32/lib/ruby/gems/2.0.0/gems

How do I change the directory that gems are installed to to the correct one stated above? any suggestions are much appreciated :)

side note: I'm running on Windows 8


Solution

  • Sorry to prequalify this answer, but I can't speak to how RubyMine sets up gems and the gem environment. That said, you can control where gems are installed by manipulating the GEM_HOME environment variable.

    On Windows, set creates a user variable.

    > set GEM_HOME=c:\your_target_folder

    With GEM_HOME assigned, gem install xyz will install the gem to the directory you specified.

    > gem install xyz

    gem_home_example