From e4181c981350417f59876172d93cd88327f5d765 Mon Sep 17 00:00:00 2001 From: joyicecloud Date: Mon, 30 Sep 2013 21:29:29 -0700 Subject: [PATCH 01/34] Create rspec test that prints to lockfile --- ...ler-version-older-than-in-lockfile_spec.rb | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 spec/warn-bundler-version-older-than-in-lockfile_spec.rb diff --git a/spec/warn-bundler-version-older-than-in-lockfile_spec.rb b/spec/warn-bundler-version-older-than-in-lockfile_spec.rb new file mode 100644 index 00000000000..90a87dd2257 --- /dev/null +++ b/spec/warn-bundler-version-older-than-in-lockfile_spec.rb @@ -0,0 +1,45 @@ +require "spec_helper" + +describe "lockfile" do + include Bundler::GemHelpers + + it "prints out the Bundler version that generated the lockfile" do + + install_gemfile <<-G + source "file://#{gem_repo1}" + + gem "rails" + G + + lockfile_should_be <<-G + GEM + remote: file:#{gem_repo1}/ + specs: + actionmailer (2.3.2) + activesupport (= 2.3.2) + actionpack (2.3.2) + activesupport (= 2.3.2) + activerecord (2.3.2) + activesupport (= 2.3.2) + activeresource (2.3.2) + activesupport (= 2.3.2) + activesupport (2.3.2) + rails (2.3.2) + actionmailer (= 2.3.2) + actionpack (= 2.3.2) + activerecord (= 2.3.2) + activeresource (= 2.3.2) + rake (= 10.0.2) + rake (10.0.2) + + PLATFORMS + #{generic(Gem::Platform.local)} + + DEPENDENCIES + rails + + BUNDLER + G + + end +end \ No newline at end of file From d1db6917459043de7aee967ed8070850fbbf1371 Mon Sep 17 00:00:00 2001 From: joyicecloud Date: Mon, 30 Sep 2013 21:30:44 -0700 Subject: [PATCH 02/34] Prints out BUNDLER after DEPENDENCIES --- lib/bundler/definition.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 6c6a60b1bc1..6cc5b781d56 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -300,6 +300,9 @@ def to_lock handled << dep.name end + out << "\n" + out << "BUNDLER\n" + out end From acf250d0814c41c98f1f9c74fb092c7ff5588f57 Mon Sep 17 00:00:00 2001 From: joyicecloud Date: Wed, 2 Oct 2013 11:20:17 -0700 Subject: [PATCH 03/34] Add bundler version to first spec test --- ...ler-version-older-than-in-lockfile_spec.rb | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/spec/warn-bundler-version-older-than-in-lockfile_spec.rb b/spec/warn-bundler-version-older-than-in-lockfile_spec.rb index 90a87dd2257..6c90aafb720 100644 --- a/spec/warn-bundler-version-older-than-in-lockfile_spec.rb +++ b/spec/warn-bundler-version-older-than-in-lockfile_spec.rb @@ -39,7 +39,47 @@ rails BUNDLER + #{Bundler::VERSION} G end + + it "warns if the bundler version is older than the version that created" do + gemfile <<-G + source "file://#{gem_repo1}" + + gem "rails" + G + + lockfile <<-L + GEM + remote: file:#{gem_repo1}/ + specs: + actionmailer (2.3.2) + activesupport (= 2.3.2) + actionpack (2.3.2) + activesupport (= 2.3.2) + activerecord (2.3.2) + activesupport (= 2.3.2) + activeresource (2.3.2) + activesupport (= 2.3.2) + activesupport (2.3.2) + rails (2.3.2) + actionmailer (= 2.3.2) + actionpack (= 2.3.2) + activerecord (= 2.3.2) + activeresource (= 2.3.2) + rake (= 10.0.2) + rake (10.0.2) + + PLATFORMS + #{generic(Gem::Platform.local)} + + DEPENDENCIES + rails + + BUNDLER + L + + end end \ No newline at end of file From d523de59d3ddbef874555b7eaad0e2cc5274ec01 Mon Sep 17 00:00:00 2001 From: joyicecloud Date: Wed, 2 Oct 2013 11:24:10 -0700 Subject: [PATCH 04/34] Add bundler version to out --- lib/bundler/definition.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 6cc5b781d56..96015b03eba 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -302,6 +302,7 @@ def to_lock out << "\n" out << "BUNDLER\n" + out << " #{Bundler::VERSION}" out end From 2008cc229198f38d8e430db30989faef727b5a11 Mon Sep 17 00:00:00 2001 From: joyicecloud Date: Wed, 2 Oct 2013 13:01:45 -0700 Subject: [PATCH 05/34] Change bundler version in lockfile to newer version than the version install on machine --- ...rn-bundler-version-older-than-in-lockfile_spec.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/spec/warn-bundler-version-older-than-in-lockfile_spec.rb b/spec/warn-bundler-version-older-than-in-lockfile_spec.rb index 6c90aafb720..4c01dd713e5 100644 --- a/spec/warn-bundler-version-older-than-in-lockfile_spec.rb +++ b/spec/warn-bundler-version-older-than-in-lockfile_spec.rb @@ -39,7 +39,7 @@ rails BUNDLER - #{Bundler::VERSION} + #{Bundler::VERSION} # 1.4.0.rc.1 G end @@ -79,7 +79,17 @@ rails BUNDLER + #{Bundler::VERSION} L + expect(File.read(bundled_app("Gemfile.lock"))).to match("BUNDLER\n 1.3.5") + + lockfile_bundler_version = File.read(bundled_app("Gemfile.lock")).gsub(/#{Bundler::VERSION}/, "1.5.0.0") + + File.open(bundled_app("Gemfile.lock"), "wb"){|f| f.puts(lockfile_bundler_version) } + + expect(File.read(bundled_app("Gemfile.lock"))).not_to match("1.3.5") + end + end \ No newline at end of file From b390d4b46f23915c89dc22b945ea3d94d2d31221 Mon Sep 17 00:00:00 2001 From: joyicecloud Date: Wed, 2 Oct 2013 14:28:57 -0700 Subject: [PATCH 06/34] Stores bundler version --- lib/bundler/lockfile_parser.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb index 01fa86321a1..95989dca50e 100644 --- a/lib/bundler/lockfile_parser.rb +++ b/lib/bundler/lockfile_parser.rb @@ -16,6 +16,7 @@ class LockfileParser DEPENDENCIES = "DEPENDENCIES" PLATFORMS = "PLATFORMS" + BUNDLER = "BUNDLER" GIT = "GIT" GEM = "GEM" PATH = "PATH" @@ -28,6 +29,7 @@ def initialize(lockfile) @dependencies = [] @state = :source @specs = {} + @bundler ||= "" if lockfile.match(/<<<<<<<|=======|>>>>>>>|\|\|\|\|\|\|\|/) raise LockfileError, "Your Gemfile.lock contains merge conflicts.\n" \ @@ -39,6 +41,8 @@ def initialize(lockfile) @state = :dependency elsif line == PLATFORMS @state = :platform + elsif line == BUNDLER + @bundler = "#{Bundler::VERSION}" else send("parse_#{@state}", line) end From b6fa00245684c063d2b4b2b20709f325cad98751 Mon Sep 17 00:00:00 2001 From: joyicecloud Date: Wed, 2 Oct 2013 17:07:50 -0700 Subject: [PATCH 07/34] The second test adds bundle :install to include text --- spec/warn-bundler-version-older-than-in-lockfile_spec.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/warn-bundler-version-older-than-in-lockfile_spec.rb b/spec/warn-bundler-version-older-than-in-lockfile_spec.rb index 4c01dd713e5..e5a0834ae8f 100644 --- a/spec/warn-bundler-version-older-than-in-lockfile_spec.rb +++ b/spec/warn-bundler-version-older-than-in-lockfile_spec.rb @@ -88,7 +88,9 @@ File.open(bundled_app("Gemfile.lock"), "wb"){|f| f.puts(lockfile_bundler_version) } - expect(File.read(bundled_app("Gemfile.lock"))).not_to match("1.3.5") + expect(File.read(bundled_app("Gemfile.lock"))).not_to match("BUNDLER\n 1.3.5") + + expect(bundle :install).to include("Your bundle is complete!") end From 518ab345d6b9ef04477e467abcc01cab152488df Mon Sep 17 00:00:00 2001 From: joyicecloud Date: Wed, 2 Oct 2013 19:07:34 -0700 Subject: [PATCH 08/34] Add attr_reader and remove ||= --- lib/bundler/lockfile_parser.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb index 95989dca50e..967b67af6b4 100644 --- a/lib/bundler/lockfile_parser.rb +++ b/lib/bundler/lockfile_parser.rb @@ -12,7 +12,7 @@ module Bundler class LockfileParser - attr_reader :sources, :dependencies, :specs, :platforms + attr_reader :sources, :dependencies, :specs, :platforms, :bundler DEPENDENCIES = "DEPENDENCIES" PLATFORMS = "PLATFORMS" @@ -29,7 +29,7 @@ def initialize(lockfile) @dependencies = [] @state = :source @specs = {} - @bundler ||= "" + @bundler = "" if lockfile.match(/<<<<<<<|=======|>>>>>>>|\|\|\|\|\|\|\|/) raise LockfileError, "Your Gemfile.lock contains merge conflicts.\n" \ From a9408447c74bc91e63a7a1940b94fc906dca10dc Mon Sep 17 00:00:00 2001 From: joyicecloud Date: Wed, 2 Oct 2013 19:09:21 -0700 Subject: [PATCH 09/34] method to see if Bundler version in lockfile is newer than the current Bundler version that is doing the bundle installing --- lib/bundler.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/bundler.rb b/lib/bundler.rb index b537ed71568..4c4f1b86858 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -361,6 +361,13 @@ def ruby_version @ruby_version ||= SystemRubyVersion.new end + def locked_bundler_version + @locked_bundler_version = Bundler.locked_gems.bundler + if @locked_bundler_version > "#{Bundler::VERSION}" + @locked_bundler_version + end + end + private def eval_yaml_gemspec(path, contents) From 7b27bfa2b08127f7b21b2f36dacc822604f387f0 Mon Sep 17 00:00:00 2001 From: joyicecloud Date: Wed, 2 Oct 2013 19:10:31 -0700 Subject: [PATCH 10/34] Prints error msg if lockfile Bundler version newer than current Bundler version doing the bundle install --- lib/bundler/cli.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 34c32205f8c..3b6e3fa78bf 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -184,6 +184,8 @@ def check "Specify the number of jobs to run in parallel" def install + raise InstallError, "You're using an older version of Bundler (#{Bundler::VERSION}) than the one specified in your Gemfile (#{Bundler.locked_bundler_version})! Maybe you should upgrade!" if Bundler.locked_bundler_version + opts = options.dup if opts[:without] opts[:without] = opts[:without].map{|g| g.tr(' ', ':') } From e41ca07acbe6a0b9c1dcdb437b87339bd7a6cf97 Mon Sep 17 00:00:00 2001 From: joyicecloud Date: Wed, 2 Oct 2013 19:12:09 -0700 Subject: [PATCH 11/34] Throws up error :/ /lib/bundler.rb:320:in initialize': No such file or directory - /Users/joyce/ror/rails/bundler/bundler/tmp/bundled_app/Gemfile.lock (Errno::ENOENT) --- spec/warn-bundler-version-older-than-in-lockfile_spec.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/spec/warn-bundler-version-older-than-in-lockfile_spec.rb b/spec/warn-bundler-version-older-than-in-lockfile_spec.rb index e5a0834ae8f..eb6466cd9b2 100644 --- a/spec/warn-bundler-version-older-than-in-lockfile_spec.rb +++ b/spec/warn-bundler-version-older-than-in-lockfile_spec.rb @@ -84,14 +84,12 @@ expect(File.read(bundled_app("Gemfile.lock"))).to match("BUNDLER\n 1.3.5") - lockfile_bundler_version = File.read(bundled_app("Gemfile.lock")).gsub(/#{Bundler::VERSION}/, "1.5.0.0") + replace_bundler_version = File.read(bundled_app("Gemfile.lock")).gsub(/#{Bundler::VERSION}/, "1.4.0.rc.1") - File.open(bundled_app("Gemfile.lock"), "wb"){|f| f.puts(lockfile_bundler_version) } + File.open(bundled_app("Gemfile.lock"), "wb"){|f| f.puts(replace_bundler_version) } expect(File.read(bundled_app("Gemfile.lock"))).not_to match("BUNDLER\n 1.3.5") - expect(bundle :install).to include("Your bundle is complete!") - end end \ No newline at end of file From 28be5bc4aca8a02943bae83004a085ecb28efc08 Mon Sep 17 00:00:00 2001 From: joyicecloud Date: Thu, 3 Oct 2013 16:45:27 -0700 Subject: [PATCH 12/34] Change code if there isn't a lockfile in locked_gem method and locked_bundler_version method --- lib/bundler.rb | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/bundler.rb b/lib/bundler.rb index 4c4f1b86858..1443207f30e 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -154,9 +154,12 @@ def definition(unlock = nil) end def locked_gems - @locked_gems ||= begin + return @locked_gems if defined?(@locked_gems) + if Bundler.default_lockfile.exist? lock = Bundler.read_file(Bundler.default_lockfile) - LockfileParser.new(lock) + @lock_gems = LockfileParser.new(lock) + else + @locked_gems = nil end end @@ -362,9 +365,13 @@ def ruby_version end def locked_bundler_version - @locked_bundler_version = Bundler.locked_gems.bundler - if @locked_bundler_version > "#{Bundler::VERSION}" - @locked_bundler_version + if Bundler.default_lockfile.exist? + lock = Bundler.read_file(Bundler.default_lockfile) + @locked_gems = LockfileParser.new(lock) + @locked_bundler_version = @locked_gems.bundler + if @locked_bundler_version > "#{Bundler::VERSION}" + @locked_bundler_version + end end end From 916e7e871dab56f1b18eba580b021c23ced351c4 Mon Sep 17 00:00:00 2001 From: joyicecloud Date: Thu, 3 Oct 2013 16:46:40 -0700 Subject: [PATCH 13/34] Add bundle install expect out msg in spec test --- spec/warn-bundler-version-older-than-in-lockfile_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/warn-bundler-version-older-than-in-lockfile_spec.rb b/spec/warn-bundler-version-older-than-in-lockfile_spec.rb index eb6466cd9b2..c7ecb481c84 100644 --- a/spec/warn-bundler-version-older-than-in-lockfile_spec.rb +++ b/spec/warn-bundler-version-older-than-in-lockfile_spec.rb @@ -90,6 +90,8 @@ expect(File.read(bundled_app("Gemfile.lock"))).not_to match("BUNDLER\n 1.3.5") + bundle :install + expect(out).to include("You're using an older version of Bundler (#{Bundler::VERSION}) than the one specified in your Gemfile") end end \ No newline at end of file From c068c86ad6f65d58aa30a3aedcdc0ffd44e252c1 Mon Sep 17 00:00:00 2001 From: Andre Arko Date: Thu, 3 Oct 2013 17:31:36 -0700 Subject: [PATCH 14/34] put a high version directly into the lockfile --- ...rn-bundler-version-older-than-in-lockfile_spec.rb | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/spec/warn-bundler-version-older-than-in-lockfile_spec.rb b/spec/warn-bundler-version-older-than-in-lockfile_spec.rb index c7ecb481c84..6d9d23e8b75 100644 --- a/spec/warn-bundler-version-older-than-in-lockfile_spec.rb +++ b/spec/warn-bundler-version-older-than-in-lockfile_spec.rb @@ -79,19 +79,11 @@ rails BUNDLER - #{Bundler::VERSION} + 100.1 L - expect(File.read(bundled_app("Gemfile.lock"))).to match("BUNDLER\n 1.3.5") - - replace_bundler_version = File.read(bundled_app("Gemfile.lock")).gsub(/#{Bundler::VERSION}/, "1.4.0.rc.1") - - File.open(bundled_app("Gemfile.lock"), "wb"){|f| f.puts(replace_bundler_version) } - - expect(File.read(bundled_app("Gemfile.lock"))).not_to match("BUNDLER\n 1.3.5") - bundle :install - expect(out).to include("You're using an older version of Bundler (#{Bundler::VERSION}) than the one specified in your Gemfile") + expect(out).to include("You're using an older version of Bundler (#{Bundler::VERSION}) than the one specified in your Gemfile (100.1)") end end \ No newline at end of file From 8c9202796dbc095d081eae0f2fe4edecf76a91e5 Mon Sep 17 00:00:00 2001 From: Andre Arko Date: Thu, 3 Oct 2013 17:40:35 -0700 Subject: [PATCH 15/34] remove comment so expected lockfile is correct --- spec/warn-bundler-version-older-than-in-lockfile_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/warn-bundler-version-older-than-in-lockfile_spec.rb b/spec/warn-bundler-version-older-than-in-lockfile_spec.rb index 6d9d23e8b75..9a12d5dfa41 100644 --- a/spec/warn-bundler-version-older-than-in-lockfile_spec.rb +++ b/spec/warn-bundler-version-older-than-in-lockfile_spec.rb @@ -39,7 +39,7 @@ rails BUNDLER - #{Bundler::VERSION} # 1.4.0.rc.1 + #{Bundler::VERSION} G end From cdd978bc3385b2bd283a2aa2b0c763282bc66844 Mon Sep 17 00:00:00 2001 From: Andre Arko Date: Thu, 3 Oct 2013 17:46:33 -0700 Subject: [PATCH 16/34] parse the bundler version out of the lock the old code was just using the version of Bundler that was running, not actually reading the version of Bundler that was in the lockfile. --- lib/bundler/lockfile_parser.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb index 967b67af6b4..d15f8bfd2ec 100644 --- a/lib/bundler/lockfile_parser.rb +++ b/lib/bundler/lockfile_parser.rb @@ -42,7 +42,7 @@ def initialize(lockfile) elsif line == PLATFORMS @state = :platform elsif line == BUNDLER - @bundler = "#{Bundler::VERSION}" + @state = :bundler else send("parse_#{@state}", line) end @@ -144,5 +144,11 @@ def parse_platform(line) end end + def parse_bundler(line) + if line =~ /^ (.*)$/ + @bundler = Gem::Version.new($1) + end + end + end end From 4176b2bf683954b8a901075913179b2538467afa Mon Sep 17 00:00:00 2001 From: Andre Arko Date: Thu, 3 Oct 2013 17:49:16 -0700 Subject: [PATCH 17/34] switch to a warning for old bundlers we actually want to warn people that they should upgrade, not force them to always have to upgrade if they want to install. --- lib/bundler/cli.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 3b6e3fa78bf..94f1ef19113 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -184,8 +184,6 @@ def check "Specify the number of jobs to run in parallel" def install - raise InstallError, "You're using an older version of Bundler (#{Bundler::VERSION}) than the one specified in your Gemfile (#{Bundler.locked_bundler_version})! Maybe you should upgrade!" if Bundler.locked_bundler_version - opts = options.dup if opts[:without] opts[:without] = opts[:without].map{|g| g.tr(' ', ':') } @@ -276,6 +274,12 @@ def install end clean if Bundler.settings[:clean] && Bundler.settings[:path] + + if Bundler.locked_bundler_version + Bundler.ui.warn "You're using an older version of Bundler (#{Bundler::VERSION}) than " \ + "the one specified in your Gemfile (#{Bundler.locked_bundler_version})!" \ + "Please upgrade by running `gem install bundler`." + end rescue GemNotFound, VersionConflict => e if opts[:local] && Bundler.app_cache.exist? Bundler.ui.warn "Some gems seem to be missing from your vendor/cache directory." From ffaa321783f3c115975889a7702919a08f92c67e Mon Sep 17 00:00:00 2001 From: Andre Arko Date: Thu, 3 Oct 2013 17:50:46 -0700 Subject: [PATCH 18/34] rename LockfileParser#bundler to bundler_version --- lib/bundler/lockfile_parser.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb index d15f8bfd2ec..7184caa7590 100644 --- a/lib/bundler/lockfile_parser.rb +++ b/lib/bundler/lockfile_parser.rb @@ -12,7 +12,7 @@ module Bundler class LockfileParser - attr_reader :sources, :dependencies, :specs, :platforms, :bundler + attr_reader :sources, :dependencies, :specs, :platforms, :bundler_version DEPENDENCIES = "DEPENDENCIES" PLATFORMS = "PLATFORMS" @@ -29,7 +29,6 @@ def initialize(lockfile) @dependencies = [] @state = :source @specs = {} - @bundler = "" if lockfile.match(/<<<<<<<|=======|>>>>>>>|\|\|\|\|\|\|\|/) raise LockfileError, "Your Gemfile.lock contains merge conflicts.\n" \ @@ -146,7 +145,7 @@ def parse_platform(line) def parse_bundler(line) if line =~ /^ (.*)$/ - @bundler = Gem::Version.new($1) + @bundler_version = Gem::Version.new($1) end end From d31ea3780fe9526ad70410f9f0cd054294cc624b Mon Sep 17 00:00:00 2001 From: Andre Arko Date: Thu, 3 Oct 2013 17:53:24 -0700 Subject: [PATCH 19/34] rename Bundler.locked_gems to Bundler.lock it's not actually a list of locked gems, it's the LockfileParser that has parsed the current lock. so let's just call it a lock. --- lib/bundler.rb | 8 ++++---- lib/bundler/cli.rb | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/bundler.rb b/lib/bundler.rb index 1443207f30e..7fa73c04349 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -153,13 +153,13 @@ def definition(unlock = nil) end end - def locked_gems - return @locked_gems if defined?(@locked_gems) + def lock + return @lock if defined?(@lock) if Bundler.default_lockfile.exist? lock = Bundler.read_file(Bundler.default_lockfile) - @lock_gems = LockfileParser.new(lock) + @lock = LockfileParser.new(lock) else - @locked_gems = nil + @lock = nil end end diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 94f1ef19113..1e14dfc41e2 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -327,7 +327,7 @@ def update(*gems) Bundler.definition(true) else # cycle through the requested gems, just to make sure they exist - names = Bundler.locked_gems.specs.map{ |s| s.name } + names = Bundler.lock.specs.map{ |s| s.name } gems.each do |g| next if names.include?(g) raise GemNotFound, not_found_message(g, names) From 779b9fd3ef2c8d3ef7de3cfbe28bbc52a3b32904 Mon Sep 17 00:00:00 2001 From: Andre Arko Date: Thu, 3 Oct 2013 18:11:34 -0700 Subject: [PATCH 20/34] just use Bundler.lock.bundler_version we already have a LockfileParser in Bundler.lock, so we can just use that one to get the locking Bundler version, instead of writing a new method that just gets us the Bundler version. --- lib/bundler.rb | 11 ----------- lib/bundler/cli.rb | 4 ++-- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/lib/bundler.rb b/lib/bundler.rb index 7fa73c04349..5942ab154a1 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -364,17 +364,6 @@ def ruby_version @ruby_version ||= SystemRubyVersion.new end - def locked_bundler_version - if Bundler.default_lockfile.exist? - lock = Bundler.read_file(Bundler.default_lockfile) - @locked_gems = LockfileParser.new(lock) - @locked_bundler_version = @locked_gems.bundler - if @locked_bundler_version > "#{Bundler::VERSION}" - @locked_bundler_version - end - end - end - private def eval_yaml_gemspec(path, contents) diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 1e14dfc41e2..ff20859174c 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -275,9 +275,9 @@ def install clean if Bundler.settings[:clean] && Bundler.settings[:path] - if Bundler.locked_bundler_version + if Bundler.lock.bundler_version > Gem::Version.new(Bundler::VERSION) Bundler.ui.warn "You're using an older version of Bundler (#{Bundler::VERSION}) than " \ - "the one specified in your Gemfile (#{Bundler.locked_bundler_version})!" \ + "the one specified in your Gemfile (#{Bundler.lock.bundler_version})!" \ "Please upgrade by running `gem install bundler`." end rescue GemNotFound, VersionConflict => e From 4ffaba420781494fa017413c05106d1f3ad722d9 Mon Sep 17 00:00:00 2001 From: Andre Arko Date: Thu, 3 Oct 2013 18:12:30 -0700 Subject: [PATCH 21/34] save the locking bundler version before re-locking running the installer will write out a new lock file, because that is what installing does. so we save the bundler version before the installer runs, so we can check it later to print a warning about being out of date. --- lib/bundler/cli.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index ff20859174c..bba9628e74f 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -248,6 +248,7 @@ def install Bundler.ui.level = "warn" if opts[:quiet] Bundler::Fetcher.disable_endpoint = opts["full-index"] Bundler.settings[:disable_shared_gems] = Bundler.settings[:path] ? '1' : nil + locking_bundler_version = Bundler.lock.bundler_version # rubygems plugins sometimes hook into the gem install process Gem.load_env_plugins if Gem.respond_to?(:load_env_plugins) @@ -275,9 +276,9 @@ def install clean if Bundler.settings[:clean] && Bundler.settings[:path] - if Bundler.lock.bundler_version > Gem::Version.new(Bundler::VERSION) + if locking_bundler_version > Gem::Version.new(Bundler::VERSION) Bundler.ui.warn "You're using an older version of Bundler (#{Bundler::VERSION}) than " \ - "the one specified in your Gemfile (#{Bundler.lock.bundler_version})!" \ + "the one specified in your Gemfile (#{locking_bundler_version})!" \ "Please upgrade by running `gem install bundler`." end rescue GemNotFound, VersionConflict => e From 41e02ab7e9c6be4f80463b07bbfcd5d4bd442f4e Mon Sep 17 00:00:00 2001 From: joyicecloud Date: Wed, 2 Oct 2013 14:27:40 -0700 Subject: [PATCH 22/34] Add gemfile to first spec test --- ...ler-version-older-than-in-lockfile_spec.rb | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/spec/warn-bundler-version-older-than-in-lockfile_spec.rb b/spec/warn-bundler-version-older-than-in-lockfile_spec.rb index 9a12d5dfa41..96d71c17b37 100644 --- a/spec/warn-bundler-version-older-than-in-lockfile_spec.rb +++ b/spec/warn-bundler-version-older-than-in-lockfile_spec.rb @@ -11,6 +11,37 @@ gem "rails" G + lockfile <<-G + GEM + remote: file:#{gem_repo1}/ + specs: + actionmailer (2.3.2) + activesupport (= 2.3.2) + actionpack (2.3.2) + activesupport (= 2.3.2) + activerecord (2.3.2) + activesupport (= 2.3.2) + activeresource (2.3.2) + activesupport (= 2.3.2) + activesupport (2.3.2) + rails (2.3.2) + actionmailer (= 2.3.2) + actionpack (= 2.3.2) + activerecord (= 2.3.2) + activeresource (= 2.3.2) + rake (= 10.0.2) + rake (10.0.2) + + PLATFORMS + #{generic(Gem::Platform.local)} + + DEPENDENCIES + rails + + BUNDLER + #{Bundler::VERSION} + G + lockfile_should_be <<-G GEM remote: file:#{gem_repo1}/ From 7509d31fe772f9c51b6140a611e77f9ba4be5ea7 Mon Sep 17 00:00:00 2001 From: joyicecloud Date: Fri, 4 Oct 2013 16:31:37 -0700 Subject: [PATCH 23/34] Add code to fix rspec errors --- lib/bundler/cli.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index bba9628e74f..7619ac36ab8 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -248,7 +248,7 @@ def install Bundler.ui.level = "warn" if opts[:quiet] Bundler::Fetcher.disable_endpoint = opts["full-index"] Bundler.settings[:disable_shared_gems] = Bundler.settings[:path] ? '1' : nil - locking_bundler_version = Bundler.lock.bundler_version + locking_bundler_version = Bundler.lock.bundler_version if Bundler.lock # rubygems plugins sometimes hook into the gem install process Gem.load_env_plugins if Gem.respond_to?(:load_env_plugins) @@ -276,10 +276,10 @@ def install clean if Bundler.settings[:clean] && Bundler.settings[:path] - if locking_bundler_version > Gem::Version.new(Bundler::VERSION) + if locking_bundler_version && locking_bundler_version > Gem::Version.new(Bundler::VERSION) Bundler.ui.warn "You're using an older version of Bundler (#{Bundler::VERSION}) than " \ "the one specified in your Gemfile (#{locking_bundler_version})!" \ - "Please upgrade by running `gem install bundler`." + " Please upgrade by running `gem install bundler`." end rescue GemNotFound, VersionConflict => e if opts[:local] && Bundler.app_cache.exist? From 615450b7d9aa1e40363ad629fcbc5c7f84ce1efe Mon Sep 17 00:00:00 2001 From: joyicecloud Date: Fri, 4 Oct 2013 16:54:57 -0700 Subject: [PATCH 24/34] Remove lockfile in spec test --- ...ler-version-older-than-in-lockfile_spec.rb | 34 ++----------------- 1 file changed, 2 insertions(+), 32 deletions(-) diff --git a/spec/warn-bundler-version-older-than-in-lockfile_spec.rb b/spec/warn-bundler-version-older-than-in-lockfile_spec.rb index 96d71c17b37..f3f2ec41621 100644 --- a/spec/warn-bundler-version-older-than-in-lockfile_spec.rb +++ b/spec/warn-bundler-version-older-than-in-lockfile_spec.rb @@ -11,37 +11,6 @@ gem "rails" G - lockfile <<-G - GEM - remote: file:#{gem_repo1}/ - specs: - actionmailer (2.3.2) - activesupport (= 2.3.2) - actionpack (2.3.2) - activesupport (= 2.3.2) - activerecord (2.3.2) - activesupport (= 2.3.2) - activeresource (2.3.2) - activesupport (= 2.3.2) - activesupport (2.3.2) - rails (2.3.2) - actionmailer (= 2.3.2) - actionpack (= 2.3.2) - activerecord (= 2.3.2) - activeresource (= 2.3.2) - rake (= 10.0.2) - rake (10.0.2) - - PLATFORMS - #{generic(Gem::Platform.local)} - - DEPENDENCIES - rails - - BUNDLER - #{Bundler::VERSION} - G - lockfile_should_be <<-G GEM remote: file:#{gem_repo1}/ @@ -114,7 +83,8 @@ L bundle :install - expect(out).to include("You're using an older version of Bundler (#{Bundler::VERSION}) than the one specified in your Gemfile (100.1)") + expect(out).to include("You're using an older version of Bundler (#{ + Bundler::VERSION}) than the one specified in your Gemfile (100.1)") end end \ No newline at end of file From fc976f04233c79b1d1ca9fbfe5abb9feb1de5db5 Mon Sep 17 00:00:00 2001 From: joyicecloud Date: Tue, 8 Oct 2013 16:49:20 -0700 Subject: [PATCH 25/34] Add bundler version to lockfile_should_be() method --- spec/support/matchers.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb index e42c67be57e..2a1d8162d10 100644 --- a/spec/support/matchers.rb +++ b/spec/support/matchers.rb @@ -71,6 +71,8 @@ def lockfile_should_be(expected) should_be_locked spaces = expected[/\A\s+/, 0] || "" expected.gsub!(/^#{spaces}/, '') + bundler_version = "\nBUNDLER\n #{Bundler::VERSION}\n" + expected.gsub!(/\z/, bundler_version) unless expected.match(/BUNDLER/) expect(bundled_app("Gemfile.lock").read).to eq(expected) end end From 5341c851f15f18d8ead441500d7228a814f93dd8 Mon Sep 17 00:00:00 2001 From: joyicecloud Date: Tue, 8 Oct 2013 20:35:09 -0700 Subject: [PATCH 26/34] fix failing specs --- spec/install/post_bundle_message_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/install/post_bundle_message_spec.rb b/spec/install/post_bundle_message_spec.rb index 6bd4e8575d9..514a9cc248d 100644 --- a/spec/install/post_bundle_message_spec.rb +++ b/spec/install/post_bundle_message_spec.rb @@ -16,7 +16,7 @@ let(:bundle_show_message) {"Use `bundle show [gemname]` to see where a bundled gem is installed."} let(:bundle_deployment_message) {"It was installed into ./vendor"} let(:bundle_complete_message) {"Your bundle is complete!"} - let(:bundle_updated_message) {"Your bundle is updated!"} + let(:bundle_updated_message) {"Run `bundle update GEM` to update a specific gem. Run `bundle update --force` if you really want to update all gems."} describe "for fresh bundle install" do it "without any options" do @@ -120,22 +120,22 @@ it "with --without one group" do bundle :install, :without => :emo - bundle :update expect(out).to include("Gems in the group emo were not installed") + bundle :update expect(out).to include(bundle_updated_message) end it "with --without two groups" do bundle "install --without emo test" - bundle :update expect(out).to include("Gems in the groups emo and test were not installed") + bundle :update expect(out).to include(bundle_updated_message) end it "with --without more groups" do bundle "install --without emo obama test" - bundle :update expect(out).to include("Gems in the groups emo, obama and test were not installed") + bundle :update expect(out).to include(bundle_updated_message) end end From f09bf73586ec973d0d13426ebb0c7295dc05d241 Mon Sep 17 00:00:00 2001 From: joyicecloud Date: Wed, 9 Oct 2013 11:27:12 -0700 Subject: [PATCH 27/34] make the spec test for 'fixes corrupted lockfiles' pass --- spec/lock/lockfile_spec.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/lock/lockfile_spec.rb b/spec/lock/lockfile_spec.rb index e9c79483252..58a642d2053 100644 --- a/spec/lock/lockfile_spec.rb +++ b/spec/lock/lockfile_spec.rb @@ -761,6 +761,9 @@ DEPENDENCIES omg! + + BUNDLER + #{Bundler::VERSION} L end From fe94b1391463e6a4963b48e7b301e8cdb904e721 Mon Sep 17 00:00:00 2001 From: joyicecloud Date: Wed, 9 Oct 2013 14:04:34 -0700 Subject: [PATCH 28/34] Remove --all option from bundle update --- lib/bundler/cli.rb | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 7619ac36ab8..e8492311353 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -310,8 +310,6 @@ def install "Only output warnings and errors." method_option "full-index", :type => :boolean, :banner => "Use the rubygems modern index instead of the API endpoint" - method_option "all", :type => :boolean, :banner => - "updates all gems" def update(*gems) sources = Array(options[:source]) Bundler.ui.level = "warn" if options[:quiet] @@ -319,11 +317,7 @@ def update(*gems) if gems.empty? && !options[:force] Bundler.ui.error "Run `bundle update GEM` to update a specific gem. Run `bundle update --force` if you really want to update all gems." exit 1 - end - - if !options[:all] && gems.empty? && sources.empty? - return Bundler.ui.info("Are you sure you want to update every single gem in your bundle?!\n\nIf yes, run bundle update --all.\nIf you want to update an individual gem, run bundle update .\nIf not, have a good day!") - elsif options[:all] && gems.empty? && sources.empty? + elsif options[:force] && gems.empty? && sources.empty? # We're doing a full update Bundler.definition(true) else From 9ba012888922fd337a2fdc181fcf5bb966d1639f Mon Sep 17 00:00:00 2001 From: joyicecloud Date: Wed, 9 Oct 2013 14:54:06 -0700 Subject: [PATCH 29/34] Fix spec test's msg for bundle update --- spec/update/gems_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/update/gems_spec.rb b/spec/update/gems_spec.rb index ba0e498d6d9..4fc4209cbe2 100644 --- a/spec/update/gems_spec.rb +++ b/spec/update/gems_spec.rb @@ -3,7 +3,7 @@ describe "bundle update" do it "prints a message" do bundle "update" - expect(out).to include("Are you sure you want to update every single gem in your bundle?!\n\nIf yes, run bundle update --all.\nIf you want to update an individual gem, run bundle update .\nIf not, have a good day!") + expect(out).to include("Run `bundle update GEM` to update a specific gem. Run `bundle update --force` if you really want to update all gems.") end it "does not print bundle was updated" do From fd1d79936868b91ef30d77753a0952f6a7c68f40 Mon Sep 17 00:00:00 2001 From: joyicecloud Date: Wed, 9 Oct 2013 16:22:06 -0700 Subject: [PATCH 30/34] change bundle update to bundle update --force --- spec/install/git_spec.rb | 2 +- spec/update/gems_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/install/git_spec.rb b/spec/install/git_spec.rb index e25375b66b6..e7022ce0b3e 100644 --- a/spec/install/git_spec.rb +++ b/spec/install/git_spec.rb @@ -907,7 +907,7 @@ end G - bundle "update", :env => {"PATH" => ""} + bundle "update --force", :env => {"PATH" => ""} expect(out).to include("You need to install git to be able to use gems from git repositories. For help installing git, please refer to GitHub's tutorial at https://help.github.com/articles/set-up-git") end end diff --git a/spec/update/gems_spec.rb b/spec/update/gems_spec.rb index 4fc4209cbe2..2c774b10fda 100644 --- a/spec/update/gems_spec.rb +++ b/spec/update/gems_spec.rb @@ -12,7 +12,7 @@ end end -describe "bundle update --all" do +describe "bundle update --force" do before :each do build_repo2 From ba0103cb0d70578b606bfb550b9bcba0385fdd24 Mon Sep 17 00:00:00 2001 From: joyicecloud Date: Wed, 9 Oct 2013 17:07:56 -0700 Subject: [PATCH 31/34] change bundle update to bundle update --force --- spec/other/platform_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/other/platform_spec.rb b/spec/other/platform_spec.rb index b9bfae5cf2a..eb8a85e75e2 100644 --- a/spec/other/platform_spec.rb +++ b/spec/other/platform_spec.rb @@ -528,7 +528,7 @@ def should_be_patchlevel_incorrect(opts = {:exitstatus => true}) build_gem "activesupport", "3.0" end - bundle :update, :exitstatus => true + bundle 'update --force', :exitstatus => true should_be_patchlevel_incorrect end end From 27eea6f1f47a56a50cddbe3435d2a02cfdf4bde6 Mon Sep 17 00:00:00 2001 From: joyicecloud Date: Wed, 9 Oct 2013 18:07:22 -0700 Subject: [PATCH 32/34] remove :: --- lib/bundler/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bundler/version.rb b/lib/bundler/version.rb index 5da431947b7..dddd10c8fcf 100644 --- a/lib/bundler/version.rb +++ b/lib/bundler/version.rb @@ -2,5 +2,5 @@ module Bundler # We're doing this because we might write tests that deal # with other versions of bundler and we are unsure how to # handle this better. - VERSION = "1.4.0.rc.1" unless defined?(::Bundler::VERSION) + VERSION = "1.4.0.rc.1" unless defined?(Bundler::VERSION) end From 0b1932cdf5a1c8f7197b3daf6f1433d98229d58d Mon Sep 17 00:00:00 2001 From: joyicecloud Date: Thu, 10 Oct 2013 16:52:40 -0700 Subject: [PATCH 33/34] Change file permission to allow to write to Gemfile.lock --- spec/runtime/setup_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index 00e8e1bccaa..2003ecb21ec 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -374,7 +374,7 @@ Dir["**/*"].each do |f| File.directory?(f) ? File.chmod(0555, f) : - File.chmod(0444, f) + File.chmod(0644, f) end should_be_installed "rack 1.0.0" ensure From 2d115e0d1c3daf034dee751c0c35b864cefb085f Mon Sep 17 00:00:00 2001 From: joyicecloud Date: Fri, 11 Oct 2013 16:25:24 -0700 Subject: [PATCH 34/34] I don't think this is right, o well --- spec/lock/lockfile_spec.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spec/lock/lockfile_spec.rb b/spec/lock/lockfile_spec.rb index 58a642d2053..7e7297ccec6 100644 --- a/spec/lock/lockfile_spec.rb +++ b/spec/lock/lockfile_spec.rb @@ -778,10 +778,11 @@ def set_lockfile_mtime_to_known_value source "file://#{gem_repo2}" gem "rack" G - set_lockfile_mtime_to_known_value + #set_lockfile_mtime_to_known_value end it "generates Gemfile.lock with \\n line endings" do + set_lockfile_mtime_to_known_value expect(File.read(bundled_app("Gemfile.lock"))).not_to match("\r\n") should_be_installed "rack 1.0" end @@ -789,6 +790,7 @@ def set_lockfile_mtime_to_known_value context "during updates" do it "preserves Gemfile.lock \\n line endings" do + set_lockfile_mtime_to_known_value update_repo2 expect { bundle "update --force" }.to change { File.mtime(bundled_app('Gemfile.lock')) } @@ -797,6 +799,7 @@ def set_lockfile_mtime_to_known_value end it "preserves Gemfile.lock \\n\\r line endings" do + set_lockfile_mtime_to_known_value update_repo2 win_lock = File.read(bundled_app("Gemfile.lock")).gsub(/\n/, "\r\n") File.open(bundled_app("Gemfile.lock"), "wb"){|f| f.puts(win_lock) } @@ -811,6 +814,7 @@ def set_lockfile_mtime_to_known_value context "when nothing changes" do it "preserves Gemfile.lock \\n line endings" do + File.mtime(bundled_app('Gemfile.lock')) expect { ruby <<-RUBY require 'rubygems' require 'bundler' @@ -820,9 +824,9 @@ def set_lockfile_mtime_to_known_value end it "preserves Gemfile.lock \\n\\r line endings" do + mtime = File.mtime(bundled_app('Gemfile.lock')) win_lock = File.read(bundled_app("Gemfile.lock")).gsub(/\n/, "\r\n") File.open(bundled_app("Gemfile.lock"), "wb"){|f| f.puts(win_lock) } - set_lockfile_mtime_to_known_value expect { ruby <<-RUBY require 'rubygems'