Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
[ParallelInstaller] Do not deadlock when the lockfile is missing depe…
Browse files Browse the repository at this point in the history
…ndencies entirely
  • Loading branch information
segiddins committed Mar 14, 2017
1 parent ec7fa9a commit eefb983
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/bundler/installer/parallel_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ def all_dependencies
def to_s
"#<#{self.class} #{@spec.full_name} (#{state})>"
end

def full_name
@spec.full_name
end
end

def self.call(*args)
Expand Down Expand Up @@ -164,7 +168,11 @@ def check_for_corrupt_lockfile
warning << "* #{missing.map(&:name).join(", ")} depended upon by #{spec.name}"
end

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

fatally_missing_specs = missing_dependencies.map(&:last).flatten.map(&:name) - @specs.map(&:name)
return Bundler.ui.warning(warning) if fatally_missing_specs.empty?
raise InstallError, warning.concat("\n\nBundler is unable to continue installing without #{fatal.join(",")} in the lockfile.")
end

def require_tree_for_spec(spec)
Expand Down
29 changes: 29 additions & 0 deletions spec/lock/lockfile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1258,6 +1258,35 @@
L
end

it "does not deadlock when the lockfile is missing dependencies entirely" do
lockfile <<-L
GEM
remote: file:#{gem_repo1}/
specs:
thin (1.0)
PLATFORMS
ruby
DEPENDENCIES
thin
L

install_gemfile <<-G
source "file://#{gem_repo1}"
gem "thin"
G

expect(out).to end_with(<<-S.strip)
Your lockfile was created by an old Bundler that left some things out.
You can fix this by adding the missing gems to your Gemfile, running bundle install, and then removing the gems from your Gemfile.
The missing gems are:
* rack depended upon by thin
Bundler is unable to continue installing without rack in the lockfile.
S
end

describe "a line ending" do
def set_lockfile_mtime_to_known_value
time = Time.local(2000, 1, 1, 0, 0, 0)
Expand Down

0 comments on commit eefb983

Please sign in to comment.