Problem with GEM_PATH in new Rbenv install #368

Closed
brandonparsons opened this Issue Mar 23, 2013 · 3 comments

Comments

Projects
None yet
2 participants

Hi there!

I've been using Rbenv for a while, and am having a new problem that I haven't run in to before - was hoping you could help.

I'm "deploying" my application to a vagrant box, and using chef-ruby_build and chef-rbenv to set up the environment. I have tried both the system_install and user install versions.

The installation of Ruby works just fine (i.e. ruby -v outputs the correct value), however I keep getting failures along the lines of LoadError: cannot load such file -- GEM. I tried a gem env, and it is only outputting the normal Ruby gem directory - i.e. rbenv (or something) is not updating my GEM_PATH to include rbenv installed gems.

I expect there might be a simple fix, but I'm confused as to why I'm getting this error now, and was not before.

Any help would be appreciated!

brandon@app01:~$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.23
  - RUBY VERSION: 1.9.3 (2013-02-22 patchlevel 392) [x86_64-linux]
  - INSTALLATION DIRECTORY: /home/vagrant/local/ruby/gems
  - RUBY EXECUTABLE: /usr/local/rbenv/versions/1.9.3-p392/bin/ruby
  - EXECUTABLE DIRECTORY: /home/vagrant/local/ruby/gems/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /home/vagrant/local/ruby/gems
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gem" => "--no-ri --no-rdoc"
     - "install" => "--no-ri --no-rdoc"
     - "update" => "--no-ri --no-rdoc"
  - REMOTE SOURCES:
     - http://rubygems.org/
Collaborator

mislav commented Mar 24, 2013

In the environment where you ran gem env, something has set up GEM_HOME and GEM_PATH to be /home/vagrant/local/ruby/gems, as evident by the output above. This isn't the default directory for RubyGems, so it was likely set up by Chef recipes.

If your gems were installed in the same location (you could check that by inspecting the directory), ruby should be able to use them. You didn't tell us how or where did you install the gems, however. If they were installed somewhere else, perhaps in the default system location for RubyGems ($(rbenv prefix)/lib/ruby/gems/1.9.1), then this explains why you couldn't load them at runtime.

Anyway, check your GEM_HOME and GEM_PATH in different scenarios. Closing because this is a setup issue, not a bug with rbenv.

mislav closed this Mar 24, 2013

Hi there - thanks for the quick reply. No issues closing it.

I was installing the gems via a Chef recipe, and as you mentioned, they did end up in the default system area - $(rbenv prefix)/lib/ruby/gems/1.9.1 . I'm not entirely sure where I want to be installing these gems in production, I'll have to sort it out.

What do most people do with GEM_HOME and GEM_PATH in production? Just set to the deploy user's home directory/.gem ?

Collaborator

mislav commented Mar 24, 2013

Most people seem to prefer installing several important gems (like Bundler) system wide, then use Bundler's --path or even --standalone settings to install dependencies per-application. That way an application is almost entirely self-contained.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment