Skip to content

Instantly share code, notes, and snippets.

@BugRoger
Created July 10, 2012 15:59
Show Gist options
  • Save BugRoger/3084317 to your computer and use it in GitHub Desktop.
Save BugRoger/3084317 to your computer and use it in GitHub Desktop.
How to load global gems not defined in a Gemfile...
begin
# Blerg. Mess global gems into the load path. This doesn't work for all gems.
# But it's good enough for basic irb gems.
if defined?(::Bundler)
global_gemset = ENV['GEM_PATH'].split(':').grep(/ruby.*@global/).first
if global_gemset
all_global_gem_paths = Dir.glob("#{global_gemset}/gems/*")
all_global_gem_paths.each do |p|
gem_path = "#{p}/lib"
$LOAD_PATH << gem_path
end
end
end
require "awesome_print"
IRB::Irb.class_eval do
def output_value
ap @context.last_value
end
end
rescue Exception => e
warn "Error loading irbrc: #{e}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment