def install(path = nil)
opts = options.dup
opts[:without] ||= []
if opts[:without].size == 1
opts[:without].map!{|g| g.split(" ") }
opts[:without].flatten!
end
opts[:without].map!{|g| g.to_sym }
ENV['BUNDLE_GEMFILE'] = File.expand_path(opts[:gemfile]) if opts[:gemfile]
ENV['RB_USER_INSTALL'] = '1' if Bundler::FREEBSD
Bundler.ui.shell = Thor::Shell::Basic.new if opts[:deployment]
if opts[:production]
opts[:deployment] = true
Bundler.ui.warn "The --production option is deprecated, and will be removed in " \
"the final release of Bundler 1.0. Please use --deployment instead."
end
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
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[:disable_shared_gems] = '1' if Bundler.settings[:path]
Bundler.settings.without = opts[:without] unless opts[:without].empty?
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 = Bundler.settings[:path]
relative_path = "./" + relative_path unless relative_path[0] == ?/
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.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