def install
opts = options.dup
if opts[:without]
opts[:without].map!{|g| g.split(" ") }
opts[:without].flatten!
opts[:without].map!{|g| g.to_sym }
end
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[: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 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
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] = opts[:path] if opts[:path]
Bundler.settings[:path] ||= "bundle" if opts[:standalone]
Bundler.settings[:bin] = opts["binstubs"] if opts[:binstubs]
Bundler.settings[:shebang] = opts["shebang"] if opts[:shebang]
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]
Bundler.settings[:clean] = opts[:clean] if opts[:clean]
Bundler::Fetcher.disable_endpoint = opts["full-index"]
Gem.load_env_plugins if Gem.respond_to?(:load_env_plugins)
definition = Bundler.definition
definition.validate_ruby!
Installer.install(Bundler.root, definition, opts)
Bundler.load.cache if Bundler.root.join("vendor/cache").exist? && !options["no-cache"]
if Bundler.settings[:path]
absolute_path = File.expand_path(Bundler.settings[:path])
relative_path = absolute_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
Installer.post_install_messages.to_a.each do |name, msg|
Bundler.ui.confirm "Post-install message from #{name}:\n#{msg}"
end
clean if Bundler.settings[:clean] && Bundler.settings[:path]
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 has no remote sources. If you need " \
"gems that are not already on\nyour machine, add a line like this " \
"to your Gemfile:\n source 'https://rubygems.org'"
end
raise e
end