Search code examples
rubyrubygemsrbenv

After installing rbenv I need to add require 'rubygems'


I replaced rvm with rbenv on my Macbook and after doing so I've needed to add require 'rubygems' to things to get them working.

Is there a way of forcing rubygems to be required, or removing the need for it?


Solution

  • For sanity reasons you should always require what you need. As rubygems is included by default in ruby 1.9 you should do something like:

    require 'rubygems' unless defined?(Gem)
    

    at the top of your script.