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 123
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 130
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 139
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 113
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 118
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 148
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 end
#normalize_settings (private)
[ GitHub ]# File 'lib/bundler/cli/install.rb', line 169
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 [:deployment] 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"] 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 [:force] = [:redownload] end
#run
[ GitHub ]# File 'lib/bundler/cli/install.rb', line 10
def run Bundler.ui.level = "error" if [:quiet] warn_if_root normalize_groups 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? if Bundler.feature_flag.deployment_means_frozen? Bundler.settings.set_command_option :deployment, true else Bundler.settings.set_command_option :frozen, true end 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`" 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.load.cache if Bundler.app_cache.exist? && ! ["no-cache"] && !Bundler.frozen_bundle? Bundler.ui.confirm "Bundle complete! #{dependencies_count_for(definition)}, #{gems_installed_for(definition)}." Bundler::CLI::Common. 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 "bundler/cli/clean" Bundler::CLI::Clean.new( ).run end rescue GemNotFound, VersionConflict => e if [:local] && Bundler.app_cache.exist? Bundler.ui.warn "Some gems seem to be missing from your #{Bundler.settings.app_cache_path} directory." end unless Bundler.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' WARN end raise e rescue Gem::InvalidSpecificationException => e Bundler.ui.warn "You have one or more invalid gemspecs that need to be fixed." raise e end
#warn_ambiguous_gems (private)
[ GitHub ]# File 'lib/bundler/cli/install.rb', line 204
def warn_ambiguous_gems Installer.ambiguous_gems.to_a.each do |name, installed_from_uri, *also_found_in_uris| Bundler.ui.error "Warning: the gem '#{name}' was found in multiple sources." Bundler.ui.error "Installed from: #{installed_from_uri}" Bundler.ui.error "Also found in:" also_found_in_uris.each {|uri| Bundler.ui.error " * #{uri}" } Bundler.ui.error "You should add a source requirement to restrict this gem to your preferred source." Bundler.ui.error "For example:" Bundler.ui.error " gem '#{name}', :source => '#{installed_from_uri}'" Bundler.ui.error "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 106
def warn_if_root return if Bundler.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 => true end