Skip to content

Instantly share code, notes, and snippets.

@skojin
Created January 25, 2011 13:33
Show Gist options
  • Star 22 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save skojin/794915 to your computer and use it in GitHub Desktop.
Save skojin/794915 to your computer and use it in GitHub Desktop.
workaround to load irb specific gem (loaded in .irbrc) in bundler environment, like rails3 console
# Add all gems in the global gemset to the $LOAD_PATH so they can be used in rails3 console with bundler
if defined?(::Bundler)
$LOAD_PATH.concat Dir.glob("#{ENV['rvm_path']}/gems/#{ENV['rvm_ruby_string']}@global/gems/*/lib")
end
@Heath101
Copy link

@mschulkind Thanks for posting that snippet. I've shortened it a bit, to make it a bit easier to grok:

# Add all gems in the global gemset to the $LOAD_PATH so they can be used even
# in places like 'rails console'.
if defined?(::Bundler)
  global_gemset = ENV['GEM_PATH'].split(':').grep(/ruby.*@global/).first
  $LOAD_PATH.concat(Dir.glob("#{global_gemset}/gems/*/lib")) if global_gemset
end

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