class Bundler::CLI

def install(path = nil)

def install(path = nil)
  opts = options.dup
  if opts[:without]
    opts[:without].map!{|g| g.split(" ") }
    opts[:without].flatten!
    opts[:without].map!{|g| g.to_sym }
  end
  # Can't use Bundler.settings for this because settings needs gemfile.dirname
  ENV['BUNDLE_GEMFILE'] = File.expand_path(opts[:gemfile]) if opts[:gemfile]
  ENV['RB_USER_INSTALL'] = '1' if Bundler::FREEBSD
  # Just disable color in deployment mode
  Bundler.ui.shell = Thor::Shell::Basic.new if opts[:deployment]
  if (path || opts[:path] || opts[:deployment]) && opts[:system]
    Bundler.ui.error "You have specified both a path to install your gems to, \n" \
                     "as well as --system. Please choose."
    exit 1
  end
  if path && opts[:path]
    Bundler.ui.error "You have specified a path via `bundle install #{path}` as well as\n" \
                     "by `bundle install --path #{options[:path]}`. These options are\n" \
                     "equivalent, so please use one or the other."
    exit 1
  end
  if opts["disable-shared-gems"]
    Bundler.ui.error "The disable-shared-gem option is no longer available.\n\n" \
                     "Instead, use `bundle install` to install to your system,\n" \
                     "or `bundle install --path path/to/gems` to install to an isolated\n" \
                     "location. Bundler will resolve relative paths relative to\n" \
                     "your `Gemfile`."
    exit 1
  end
  if opts[:deployment] || opts[:frozen]
    unless Bundler.default_lockfile.exist?
      flag = opts[:deployment] ? '--deployment' : '--frozen'
      raise ProductionError, "The #{flag} flag requires a Gemfile.lock. Please make " \
                             "sure you have checked your Gemfile.lock into version control " \
                             "before deploying."
    end
    if Bundler.root.join("vendor/cache").exist?
      opts[:local] = true
    end
    Bundler.settings[:frozen] = '1'
  end
  # When install is called with --no-deployment, disable deployment mode
  if opts[:deployment] == false
    Bundler.settings.delete(:frozen)
    opts[:system] = true
  end
  Bundler.settings[:path] = nil if opts[:system]
  Bundler.settings[:path] = "vendor/bundle" if opts[:deployment]
  Bundler.settings[:path] = path if path
  Bundler.settings[:path] = opts[:path] if opts[:path]
  Bundler.settings[:bin] = opts["binstubs"] if opts[:binstubs]
  Bundler.settings[:no_prune] = true if opts["no-prune"]
  Bundler.settings[:disable_shared_gems] = Bundler.settings[:path] ? '1' : nil
  Bundler.settings.without = opts[:without]
  Bundler.ui.be_quiet! if opts[:quiet]
  Installer.install(Bundler.root, Bundler.definition, opts)
  Bundler.load.cache if Bundler.root.join("vendor/cache").exist? && !options["no-cache"]
  if Bundler.settings[:path]
    relative_path = File.expand_path(Bundler.settings[:path]).sub(/^#{File.expand_path('.')}/, '.')
    Bundler.ui.confirm "Your bundle is complete! " +
      "It was installed into #{relative_path}"
  else
    Bundler.ui.confirm "Your bundle is complete! " +
      "Use `bundle show [gemname]` to see where a bundled gem is installed."
  end
  if path
    Bundler.ui.warn "The path argument to `bundle install` is deprecated. " +
      "It will be removed in version 1.1. " +
      "Please use `bundle install --path #{path}` instead."
  end
rescue GemNotFound => e
  if opts[:local] && Bundler.app_cache.exist?
    Bundler.ui.warn "Some gems seem to be missing from your vendor/cache directory."
  end
  if Bundler.definition.no_sources?
    Bundler.ui.warn "Your Gemfile doesn't have any sources. You can add one with a line like 'source :rubygems'"
  end
  raise e
end