Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions lib/bundler/cli/check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def run
Bundler.settings.set_command_option_if_given :path, options[:path]

definition = Bundler.definition
definition.ensure_equivalent_gemfile_and_lockfile
definition.validate_runtime!

begin
Expand All @@ -28,9 +29,6 @@ def run
not_installed.each {|s| Bundler.ui.error " * #{s.name} (#{s.version})" }
Bundler.ui.warn "Install missing gems with `bundle install`"
exit 1
elsif !Bundler.default_lockfile.file? && Bundler.frozen_bundle?
Bundler.ui.error "This bundle has been frozen, but there is no #{SharedHelpers.relative_lockfile_path} present"
exit 1
else
definition.lock(true) unless options[:"dry-run"]
Bundler.ui.info "The Gemfile's dependencies are satisfied"
Expand Down
52 changes: 52 additions & 0 deletions spec/commands/check_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,58 @@

bundle :check, raise_on_error: false
expect(last_command).to be_failure
expect(err).to include("Frozen mode is set, but there's no lockfile")
end

it "fails when frozen is set and the lockfile is missing a CHECKSUMS entry" do
system_gems "myrack-1.0.0", path: default_bundle_path

gemfile <<-G
source "https://gem.repo1"
gem "myrack"
G

lockfile <<-L
GEM
remote: https://gem.repo1/
specs:
myrack (1.0.0)

PLATFORMS
#{lockfile_platforms}

DEPENDENCIES
myrack

CHECKSUMS

BUNDLED WITH
#{Bundler::VERSION}
L

bundle :check, env: { "BUNDLE_FROZEN" => "true" }, raise_on_error: false
expect(exitstatus).to eq(16)
expect(err).to include("Your lockfile is missing a CHECKSUMS entry for \"myrack\", but can't be updated because frozen mode is set")
expect(out).not_to include("The Gemfile's dependencies are satisfied")
end

it "fails when frozen is set and the Gemfile has changed" do
install_gemfile <<-G
source "https://gem.repo1"
gem "myrack"
G

gemfile <<-G
source "https://gem.repo1"
gem "myrack"
gem "rails"
G

bundle :check, env: { "BUNDLE_FROZEN" => "true" }, raise_on_error: false
expect(exitstatus).to eq(16)
expect(err).to include("frozen mode is set")
expect(err).to include("* rails")
expect(out).not_to include("The Gemfile's dependencies are satisfied")
end

describe "when locked" do
Expand Down