module Bundler::SharedHelpers

def clean_load_path

def clean_load_path
  # handle 1.9 where system gems are always on the load path
  if defined?(::Gem)
    me = File.expand_path("../../", __FILE__)
    $LOAD_PATH.reject! do |p|
      next if File.expand_path(p) =~ /^#{Regexp.escape(me)}/
      p != File.dirname(__FILE__) &&
        Bundler.rubygems.gem_path.any?{|gp| p =~ /^#{Regexp.escape(gp)}/ }
    end
    $LOAD_PATH.uniq!
  end
end