Class: Bundler::CLI::Install
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/bundler/cli/install.rb |
Class Method Summary
- .new(options) ⇒ Install constructor
Instance Attribute Summary
- #options readonly
Instance Method Summary
- #run
- #check_for_group_conflicts_in_cli_options private
- #check_for_options_conflicts private
- #check_trust_policy private
- #dependencies_count_for(definition) private
- #gems_installed_for(definition) private
- #normalize_groups private
- #normalize_settings private
- #warn_ambiguous_gems private
- #warn_if_root private
Constructor Details
.new(options) ⇒ Install
# File 'lib/bundler/cli/install.rb', line 6
def initialize( ) @options = end
Instance Attribute Details
#options (readonly)
[ GitHub ]# File 'lib/bundler/cli/install.rb', line 5
attr_reader :
Instance Method Details
#check_for_group_conflicts_in_cli_options (private)
# File 'lib/bundler/cli/install.rb', line 110
def conflicting_groups = Array( [:without]) & Array( [:with]) return if conflicting_groups.empty? raise InvalidOption, "You can't list a group in both with and without." \ " The offending groups are: #{conflicting_groups.join(", ")}." end
#check_for_options_conflicts (private)
[ GitHub ]# File 'lib/bundler/cli/install.rb', line 117
def if ( [:path] || [:deployment]) && [:system] = String.new << "You have specified both --path as well as --system. Please choose only one option.\n" if [:path] << "You have specified both --deployment as well as --system. Please choose only one option.\n" if [:deployment] raise InvalidOption.new( ) end end
#check_trust_policy (private)
[ GitHub ]# File 'lib/bundler/cli/install.rb', line 126
def check_trust_policy trust_policy = ["trust-policy"] unless Bundler.rubygems.security_policies.keys.unshift(nil).include?(trust_policy) raise InvalidOption, "RubyGems doesn't know about trust policy '#{trust_policy}'. " \ "The known policies are: #{Bundler.rubygems.security_policies.keys.join(", ")}." end Bundler.settings.set_command_option_if_given :"trust-policy", trust_policy end
#dependencies_count_for(definition) (private)
[ GitHub ]# File 'lib/bundler/cli/install.rb', line 100
def dependencies_count_for(definition) count = definition.dependencies.count "#{count} Gemfile #{count == 1 ? "dependency" : "dependencies"}" end
#gems_installed_for(definition) (private)
[ GitHub ]# File 'lib/bundler/cli/install.rb', line 105
def gems_installed_for(definition) count = definition.specs.count "#{count} #{count == 1 ? "gem" : "gems"} now installed" end
#normalize_groups (private)
[ GitHub ]# File 'lib/bundler/cli/install.rb', line 135
def normalize_groups [:with] &&= [:with].join(":").tr(" ", ":").split(":") [:without] &&= [:without].join(":").tr(" ", ":").split(":") Bundler.settings.set_command_option :with, nil if [:with] == [] Bundler.settings.set_command_option :without, nil if [:without] == [] with = .fetch(:with, []) with |= Bundler.settings[:with].map(&:to_s) with -= [:without] if [:without] without = .fetch(:without, []) without |= Bundler.settings[:without].map(&:to_s) without -= [:with] if [:with] [:with] = with [:without] = without unless Bundler.settings[:without] == [:without] && Bundler.settings[:with] == [:with] # need to nil them out first to get around validation for backwards compatibility Bundler.settings.set_command_option :without, nil Bundler.settings.set_command_option :with, nil Bundler.settings.set_command_option :without, [:without] - [:with] Bundler.settings.set_command_option :with, [:with] end end
#normalize_settings (private)
[ GitHub ]# File 'lib/bundler/cli/install.rb', line 164
def normalize_settings Bundler.settings.set_command_option :path, nil if [:system] Bundler.settings.temporary(:path_relative_to_cwd => false) do Bundler.settings.set_command_option :path, "vendor/bundle" if Bundler.settings[:deployment] && Bundler.settings[:path].nil? end Bundler.settings.set_command_option_if_given :path, [:path] Bundler.settings.temporary(:path_relative_to_cwd => false) do Bundler.settings.set_command_option :path, "bundle" if ["standalone"] && Bundler.settings[:path].nil? end bin_option = ["binstubs"] bin_option = nil if bin_option && bin_option.empty? Bundler.settings.set_command_option :bin, bin_option if ["binstubs"] Bundler.settings.set_command_option_if_given :shebang, ["shebang"] Bundler.settings.set_command_option_if_given :jobs, ["jobs"] Bundler.settings.set_command_option_if_given :no_prune, ["no-prune"] Bundler.settings.set_command_option_if_given :no_install, ["no-install"] Bundler.settings.set_command_option_if_given :clean, ["clean"] normalize_groups [:force] = [:redownload] end
#run
[ GitHub ]# File 'lib/bundler/cli/install.rb', line 10
def run Bundler.ui.level = "warn" if [:quiet] warn_if_root Bundler::SharedHelpers.set_env "RB_USER_INSTALL", "1" if Bundler::FREEBSD # Disable color in deployment mode Bundler.ui.shell = Thor::Shell::Basic.new if [:deployment] check_trust_policy if [:deployment] || [:frozen] || Bundler.frozen_bundle? unless Bundler.default_lockfile.exist? flag = "--deployment flag" if [:deployment] flag ||= "--frozen flag" if [:frozen] flag ||= "deployment setting" raise ProductionError, "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." end [:local] = true if Bundler.app_cache.exist? Bundler.settings.set_command_option :deployment, true if [:deployment] Bundler.settings.set_command_option :frozen, true if [:frozen] end # When install is called with --no-deployment, disable deployment mode if [:deployment] == false Bundler.settings.set_command_option :frozen, nil [:system] = true end normalize_settings Bundler::Fetcher.disable_endpoint = ["full-index"] if ["binstubs"] Bundler::SharedHelpers.major_deprecation 2, "The --binstubs option will be removed in favor of `bundle binstubs --all`" end Plugin.gemfile_install(Bundler.default_gemfile) if Bundler.feature_flag.plugins? definition = Bundler.definition definition.validate_runtime! installer = Installer.install(Bundler.root, definition, ) Bundler.settings.temporary(:cache_all_platforms => [:local] ? false : Bundler.settings[:cache_all_platforms]) do Bundler.load.cache(nil, [:local]) if Bundler.app_cache.exist? && ! ["no-cache"] && !Bundler.frozen_bundle? end Bundler.ui.confirm "Bundle complete! #{dependencies_count_for(definition)}, #{gems_installed_for(definition)}." Bundler::CLI::Common. (:install) if Bundler.use_system_gems? Bundler.ui.confirm "Use `bundle info [gemname]` to see where a bundled gem is installed." else relative_path = Bundler.configured_bundle_path.base_path_relative_to_pwd Bundler.ui.confirm "Bundled gems are installed into `#{relative_path}`" end Bundler::CLI::Common. installer. warn_ambiguous_gems if CLI::Common.clean_after_install? require_relative "clean" Bundler::CLI::Clean.new( ).run end Bundler::CLI::Common. rescue Gem::InvalidSpecificationException Bundler.ui.warn "You have one or more invalid gemspecs that need to be fixed." raise end
#warn_ambiguous_gems (private)
[ GitHub ]# File 'lib/bundler/cli/install.rb', line 193
def warn_ambiguous_gems # TODO: remove this when we drop Bundler 1.x support Installer.ambiguous_gems.to_a.each do |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." end end
#warn_if_root (private)
[ GitHub ]# File 'lib/bundler/cli/install.rb', line 93
def warn_if_root return if Bundler.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 => true end