Class: Bundler::ParallelInstaller

Inherits:
Object
  • Object
show all
Defined in:
lib/bundler/installer/parallel_installer.rb

Defined Under Namespace

Classes: SpecInstallation

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(installer, all_specs, size, standalone, force) ⇒ ParallelInstaller

Returns a new instance of ParallelInstaller.



76
77
78
79
80
81
82
83
84
# File 'lib/bundler/installer/parallel_installer.rb', line 76

def initialize(installer, all_specs, size, standalone, force)
  @installer = installer
  @size = size
  @standalone = standalone
  @force = force
  @specs = all_specs.map {|s| SpecInstallation.new(s) }
  @spec_set = all_specs
  @rake = @specs.find {|s| s.name == "rake" }
end

Instance Attribute Details

#sizeObject (readonly)

Returns the value of attribute size.



74
75
76
# File 'lib/bundler/installer/parallel_installer.rb', line 74

def size
  @size
end

Class Method Details

.call(*args) ⇒ Object



70
71
72
# File 'lib/bundler/installer/parallel_installer.rb', line 70

def self.call(*args)
  new(*args).call
end

Instance Method Details

#callObject



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/bundler/installer/parallel_installer.rb', line 86

def call
  check_for_corrupt_lockfile

  if @rake
    do_install(@rake, 0)
    Gem::Specification.reset
  end

  if @size > 1
    install_with_worker
  else
    install_serially
  end

  check_for_unmet_dependencies

  handle_error if failed_specs.any?
  @specs
ensure
  worker_pool && worker_pool.stop
end

#check_for_corrupt_lockfileObject



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/bundler/installer/parallel_installer.rb', line 131

def check_for_corrupt_lockfile
  missing_dependencies = @specs.map do |s|
    [
      s,
      s.missing_lockfile_dependencies(@specs.map(&:name)),
    ]
  end.reject {|a| a.last.empty? }
  return if missing_dependencies.empty?

  warning = []
  warning << "Your lockfile was created by an old Bundler that left some things out."
  if @size != 1
    warning << "Because of the missing DEPENDENCIES, we can only install gems one at a time, instead of installing #{@size} at a time."
    @size = 1
  end
  warning << "You can fix this by adding the missing gems to your Gemfile, running bundle install, and then removing the gems from your Gemfile."
  warning << "The missing gems are:"

  missing_dependencies.each do |spec, missing|
    warning << "* #{missing.map(&:name).join(", ")} depended upon by #{spec.name}"
  end

  Bundler.ui.warn(warning.join("\n"))
end

#check_for_unmet_dependenciesObject



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/bundler/installer/parallel_installer.rb', line 108

def check_for_unmet_dependencies
  unmet_dependencies = @specs.map do |s|
    [
      s,
      s.dependencies.reject {|dep| @specs.any? {|spec| dep.matches_spec?(spec.spec) } },
    ]
  end.reject {|a| a.last.empty? }
  return if unmet_dependencies.empty?

  warning = []
  warning << "Your lockfile doesn't include a valid resolution."
  warning << "You can fix this by regenerating your lockfile or trying to manually editing the bad locked gems to a version that satisfies all dependencies."
  warning << "The unmet dependencies are:"

  unmet_dependencies.each do |spec, unmet_spec_dependencies|
    unmet_spec_dependencies.each do |unmet_spec_dependency|
      warning << "* #{unmet_spec_dependency}, depended upon #{spec.full_name}, unsatisfied by #{@specs.find {|s| s.name == unmet_spec_dependency.name && !unmet_spec_dependency.matches_spec?(s.spec) }.full_name}"
    end
  end

  Bundler.ui.warn(warning.join("\n"))
end