# frozen_string_literal: truemoduleBundlerclassCLI::Installattr_reader:optionsdefinitialize(options)@options=optionsenddefrunBundler.ui.level="warn"ifoptions[:quiet]warn_if_rootBundler::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?Bundler.settings.set_command_option:deployment,trueifoptions[:deployment]Bundler.settings.set_command_option:frozen,trueifoptions[:frozen]end# 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 --all`"endPlugin.gemfile_install(Bundler.default_gemfile)ifBundler.feature_flag.plugins?definition=Bundler.definitiondefinition.validate_runtime!installer=Installer.install(Bundler.root,definition,options)Bundler.settings.temporary(:cache_all_platforms=>options[:local]?false:Bundler.settings[:cache_all_platforms])doBundler.load.cache(nil,options[:local])ifBundler.app_cache.exist?&&!options["no-cache"]&&!Bundler.frozen_bundle?endBundler.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).runendBundler::CLI::Common.output_fund_metadata_summaryrescueGem::InvalidSpecificationExceptionBundler.ui.warn"You have one or more invalid gemspecs that need to be fixed."raiseendprivatedefwarn_if_rootreturnifBundler.settings[:silence_root_warning]||Gem.win_platform?||!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]=withoutunlessBundler.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]endenddefnormalize_settingsBundler.settings.set_command_option:path,nilifoptions[:system]Bundler.settings.temporary(:path_relative_to_cwd=>false)doBundler.settings.set_command_option:path,"vendor/bundle"ifBundler.settings[:deployment]&&Bundler.settings[:path].nil?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"]normalize_groupsoptions[: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