class Bundler::Runtime

def setup(*groups)

def setup(*groups)
  groups.map!(&:to_sym)
  # Has to happen first
  clean_load_path
  specs = groups.any? ? @definition.specs_for(groups) : requested_specs
  SharedHelpers.set_bundle_environment
  Bundler.rubygems.replace_entrypoints(specs)
  # Activate the specs
  load_paths = specs.map do |spec|
    unless spec.loaded_from
      raise GemNotFound, "#{spec.full_name} is missing. Run `bundle` to get it."
    end
    if (activated_spec = Bundler.rubygems.loaded_specs(spec.name)) && activated_spec.version != spec.version
      e = Gem::LoadError.new "You have already activated #{activated_spec.name} #{activated_spec.version}, " \
                             "but your Gemfile requires #{spec.name} #{spec.version}. Prepending " \
                             "`bundle exec` to your command may solve this."
      e.name = spec.name
      if e.respond_to?(:requirement=)
        e.requirement = Gem::Requirement.new(spec.version.to_s)
      else
        e.version_requirement = Gem::Requirement.new(spec.version.to_s)
      end
      raise e
    end
    Bundler.rubygems.mark_loaded(spec)
    spec.load_paths.reject {|path| $LOAD_PATH.include?(path) }
  end.reverse.flatten
  # See Gem::Specification#add_self_to_load_path (since RubyGems 1.8)
  if insert_index = Bundler.rubygems.load_path_insert_index
    # Gem directories must come after -I and ENV['RUBYLIB']
    $LOAD_PATH.insert(insert_index, *load_paths)
  else
    # We are probably testing in core, -I and RUBYLIB don't apply
    $LOAD_PATH.unshift(*load_paths)
  end
  setup_manpath
  lock(:preserve_unknown_sections => true)
  self
end