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

Commit

Permalink
Auto merge of #5516 - bundler:seg-lockfile-corrupted-no-deadlock, r=i…
Browse files Browse the repository at this point in the history
…ndirect

[ParallelInstaller] Do not deadlock when the lockfile is missing dependencies entirely

Closes #5480
  • Loading branch information
bundlerbot committed Mar 15, 2017
2 parents 3c605d0 + eefb983 commit 11c917e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ Metrics/MethodLength:
Metrics/BlockNesting:
Enabled: false

Metrics/BlockLength:
Enabled: false

Metrics/AbcSize:
Enabled: false

Expand Down
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 11c917e

Please sign in to comment.