# frozen_string_literal: truemoduleBundlerclassCLI::Installattr_reader:optionsdefinitialize(options)@options=optionsenddefrunBundler.ui.level="error"ifoptions[:quiet]warn_if_rootnormalize_groupsBundler::SharedHelpers.set_env"RB_USER_INSTALL","1"ifBundler::FREEBSD# Disable color in deployment modeBundler.ui.shell=Thor::Shell::Basic.newifoptions[:deployment]check_for_options_conflictscheck_trust_policyifoptions[:deployment]||options[:frozen]||Bundler.frozen_bundle?unlessBundler.default_lockfile.exist?flag="--deployment flag"ifoptions[:deployment]flag||="--frozen flag"ifoptions[:frozen]flag||="deployment setting"raiseProductionError,"The #{flag} requires a #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}. Please make "\"sure you have checked your #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} into version control "\"before deploying."endoptions[:local]=trueifBundler.app_cache.exist?ifBundler.feature_flag.deployment_means_frozen?Bundler.settings.set_command_option:deployment,trueelseBundler.settings.set_command_option:frozen,trueendend# When install is called with --no-deployment, disable deployment modeifoptions[:deployment]==falseBundler.settings.set_command_option:frozen,niloptions[:system]=trueendnormalize_settingsBundler::Fetcher.disable_endpoint=options["full-index"]ifoptions["binstubs"]Bundler::SharedHelpers.major_deprecation2,"The --binstubs option will be removed in favor of `bundle binstubs`"endPlugin.gemfile_install(Bundler.default_gemfile)ifBundler.feature_flag.plugins?definition=Bundler.definitiondefinition.validate_runtime!installer=Installer.install(Bundler.root,definition,options)Bundler.load.cacheifBundler.app_cache.exist?&&!options["no-cache"]&&!Bundler.frozen_bundle?Bundler.ui.confirm"Bundle complete! #{dependencies_count_for(definition)}, #{gems_installed_for(definition)}."Bundler::CLI::Common.output_without_groups_message(:install)ifBundler.use_system_gems?Bundler.ui.confirm"Use `bundle info [gemname]` to see where a bundled gem is installed."elserelative_path=Bundler.configured_bundle_path.base_path_relative_to_pwdBundler.ui.confirm"Bundled gems are installed into `#{relative_path}`"endBundler::CLI::Common.output_post_install_messagesinstaller.post_install_messageswarn_ambiguous_gemsifCLI::Common.clean_after_install?require_relative"clean"Bundler::CLI::Clean.new(options).runendrescueGemNotFound,VersionConflict=>eifoptions[:local]&&Bundler.app_cache.exist?Bundler.ui.warn"Some gems seem to be missing from your #{Bundler.settings.app_cache_path} directory."endunlessBundler.definition.has_rubygems_remotes?Bundler.ui.warn<<-WARN,:wrap=>true
Your Gemfile has no gem server sources. If you need gems that are \
not already on your machine, add a line like this to your Gemfile:
source 'https://rubygems.org'
WARNendraiseerescueGem::InvalidSpecificationException=>eBundler.ui.warn"You have one or more invalid gemspecs that need to be fixed."raiseeendprivatedefwarn_if_rootreturnifBundler.settings[:silence_root_warning]||Bundler::WINDOWS||!Process.uid.zero?Bundler.ui.warn"Don't run Bundler as root. Bundler can ask for sudo "\"if it is needed, and installing your bundle as root will break this "\"application for all non-root users on this machine.",:wrap=>trueenddefdependencies_count_for(definition)count=definition.dependencies.count"#{count} Gemfile #{count==1?"dependency":"dependencies"}"enddefgems_installed_for(definition)count=definition.specs.count"#{count}#{count==1?"gem":"gems"} now installed"enddefcheck_for_group_conflicts_in_cli_optionsconflicting_groups=Array(options[:without])&Array(options[:with])returnifconflicting_groups.empty?raiseInvalidOption,"You can't list a group in both with and without."\" The offending groups are: #{conflicting_groups.join(", ")}."enddefcheck_for_options_conflictsif(options[:path]||options[:deployment])&&options[:system]error_message=String.newerror_message<<"You have specified both --path as well as --system. Please choose only one option.\n"ifoptions[:path]error_message<<"You have specified both --deployment as well as --system. Please choose only one option.\n"ifoptions[:deployment]raiseInvalidOption.new(error_message)endenddefcheck_trust_policytrust_policy=options["trust-policy"]unlessBundler.rubygems.security_policies.keys.unshift(nil).include?(trust_policy)raiseInvalidOption,"RubyGems doesn't know about trust policy '#{trust_policy}'. "\"The known policies are: #{Bundler.rubygems.security_policies.keys.join(", ")}."endBundler.settings.set_command_option_if_given:"trust-policy",trust_policyenddefnormalize_groupsoptions[:with]&&=options[:with].join(":").tr(" ",":").split(":")options[:without]&&=options[:without].join(":").tr(" ",":").split(":")check_for_group_conflicts_in_cli_optionsBundler.settings.set_command_option:with,nilifoptions[:with]==[]Bundler.settings.set_command_option:without,nilifoptions[:without]==[]with=options.fetch(:with,[])with|=Bundler.settings[:with].map(&:to_s)with-=options[:without]ifoptions[:without]without=options.fetch(:without,[])without|=Bundler.settings[:without].map(&:to_s)without-=options[:with]ifoptions[:with]options[:with]=withoptions[:without]=withoutenddefnormalize_settingsBundler.settings.set_command_option:path,nilifoptions[:system]Bundler.settings.temporary(:path_relative_to_cwd=>false)doBundler.settings.set_command_option:path,"vendor/bundle"ifoptions[:deployment]endBundler.settings.set_command_option_if_given:path,options[:path]Bundler.settings.temporary(:path_relative_to_cwd=>false)doBundler.settings.set_command_option:path,"bundle"ifoptions["standalone"]&&Bundler.settings[:path].nil?endbin_option=options["binstubs"]bin_option=nilifbin_option&&bin_option.empty?Bundler.settings.set_command_option:bin,bin_optionifoptions["binstubs"]Bundler.settings.set_command_option_if_given:shebang,options["shebang"]Bundler.settings.set_command_option_if_given:jobs,options["jobs"]Bundler.settings.set_command_option_if_given:no_prune,options["no-prune"]Bundler.settings.set_command_option_if_given:no_install,options["no-install"]Bundler.settings.set_command_option_if_given:clean,options["clean"]unlessBundler.settings[:without]==options[:without]&&Bundler.settings[:with]==options[:with]# need to nil them out first to get around validation for backwards compatibilityBundler.settings.set_command_option:without,nilBundler.settings.set_command_option:with,nilBundler.settings.set_command_option:without,options[:without]-options[:with]Bundler.settings.set_command_option:with,options[:with]endoptions[:force]=options[:redownload]enddefwarn_ambiguous_gems# TODO: remove this when we drop Bundler 1.x supportInstaller.ambiguous_gems.to_a.eachdo|name,installed_from_uri,*also_found_in_uris|Bundler.ui.warn"Warning: the gem '#{name}' was found in multiple sources."Bundler.ui.warn"Installed from: #{installed_from_uri}"Bundler.ui.warn"Also found in:"also_found_in_uris.each{|uri|Bundler.ui.warn" * #{uri}"}Bundler.ui.warn"You should add a source requirement to restrict this gem to your preferred source."Bundler.ui.warn"For example:"Bundler.ui.warn" gem '#{name}', :source => '#{installed_from_uri}'"Bundler.ui.warn"Then uninstall the gem '#{name}' (or delete all bundled gems) and then install again."endendendend