summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2018-10-05 16:54:41 -0300
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2018-10-05 17:00:15 -0300
commit96397e584898dbdae51a3912e03b676197883dc4 (patch)
tree808dd2b37ac191fb9f07c81bf0d50aa9efdac872
parente115a839123a21365904fd86980452d2b2b0283e (diff)
downloadbundler-fix_rubygems_binstub_and_locked_version.tar.gz
Fix bad rubygems binstub + locked bundler behaviorfix_rubygems_binstub_and_locked_version
When running a rubygems bundler binstub with lock file locked to a non-installed bundler version, one would get the cryptic error message: ``` can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException) ``` where one tends to think... What? How is it not found if I just run it?!
-rw-r--r--spec/lock/lockfile_bundler_1_spec.rb38
-rw-r--r--spec/lock/lockfile_spec.rb38
2 files changed, 76 insertions, 0 deletions
diff --git a/spec/lock/lockfile_bundler_1_spec.rb b/spec/lock/lockfile_bundler_1_spec.rb
index a8615d4c89..54fa4b10ab 100644
--- a/spec/lock/lockfile_bundler_1_spec.rb
+++ b/spec/lock/lockfile_bundler_1_spec.rb
@@ -201,6 +201,44 @@ RSpec.describe "the lockfile format", :bundler => "< 2" do
G
end
+ it "outputs a warning if the current is older than lockfile's bundler version and using a rubygems binstub", :rubygems => "> 2.7.7" do
+ lockfile <<-L
+ GEM
+ remote: file://localhost#{gem_repo1}/
+ specs:
+
+ PLATFORMS
+ ruby
+
+ DEPENDENCIES
+
+ BUNDLED WITH
+ 9999
+ L
+
+ gemfile <<-G
+ source "file://localhost#{gem_repo1}"
+ G
+
+ File.open("bundle", "w") do |f|
+ f.puts("#!/usr/bin/ruby")
+ f.puts('load Gem.activate_bin_path("bundler", "bundle", ">= 0.a")')
+ end
+
+ FileUtils.chmod(0o755, "bundle")
+
+ sys_exec "./bundle --version"
+ warning_messages = [
+ "Could not find 'bundler' (9999) required by your #{bundled_app("Gemfile.lock")}",
+ "To update to the lastest version installed on your system, run `bundle update --bundler`.",
+ "To install the missing version, run `gem install bundler:9999`",
+ ]
+
+ warning_messages.each do |message|
+ expect(out).to include(message)
+ end
+ end
+
it "errors if the current is a major version older than lockfile's bundler version" do
lockfile <<-L
GEM
diff --git a/spec/lock/lockfile_spec.rb b/spec/lock/lockfile_spec.rb
index 53c832445f..f2ec869cc9 100644
--- a/spec/lock/lockfile_spec.rb
+++ b/spec/lock/lockfile_spec.rb
@@ -200,6 +200,44 @@ RSpec.describe "the lockfile format", :bundler => "2" do
G
end
+ it "outputs a warning if the current is older than lockfile's bundler version and using a rubygems binstub", :rubygems => "> 2.7.7" do
+ lockfile <<-L
+ GEM
+ remote: file://localhost#{gem_repo1}/
+ specs:
+
+ PLATFORMS
+ ruby
+
+ DEPENDENCIES
+
+ BUNDLED WITH
+ 9999
+ L
+
+ gemfile <<-G
+ source "file://localhost#{gem_repo1}"
+ G
+
+ File.open("bundle", "w") do |f|
+ f.puts("#!/usr/bin/ruby")
+ f.puts('load Gem.activate_bin_path("bundler", "bundle", ">= 0.a")')
+ end
+
+ FileUtils.chmod(0o755, "bundle")
+
+ sys_exec "./bundle --version"
+ warning_messages = [
+ "Could not find 'bundler' (9999) required by your #{bundled_app("Gemfile.lock")}",
+ "To update to the lastest version installed on your system, run `bundle update --bundler`.",
+ "To install the missing version, run `gem install bundler:9999`",
+ ]
+
+ warning_messages.each do |message|
+ expect(out).to include(message)
+ end
+ end
+
it "errors if the current is a major version older than lockfile's bundler version" do
lockfile <<-L
GEM