aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2022-05-29 16:47:22 +0200
committergit <svn-admin@ruby-lang.org>2022-05-31 16:13:52 +0900
commite2b421d679d7ebd2c7d6b44a96c8353b81e447b9 (patch)
tree69a4b40c6b6900e3fb5e4ccf3bf0810074df28e2
parent9241d75a615f652dee45bc999524cc3c6ede8c5d (diff)
downloadruby-e2b421d679d7ebd2c7d6b44a96c8353b81e447b9.tar.gz
[rubygems/rubygems] Give better conflict resolution advice
This alternative really uses only the Gemfile, and can never end up being absurd, because it will never be suggested when there's no lockfile, and it suggests deleting the lockfile. https://github.com/rubygems/rubygems/commit/5d154dd50e
-rw-r--r--lib/bundler/resolver.rb2
-rw-r--r--spec/bundler/install/gems/flex_spec.rb67
2 files changed, 65 insertions, 4 deletions
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb
index 8ec6d5dbc0..d749694952 100644
--- a/lib/bundler/resolver.rb
+++ b/lib/bundler/resolver.rb
@@ -395,7 +395,7 @@ module Bundler
o << %(\n Current #{name} version:\n #{SharedHelpers.pretty_dependency(@metadata_requirements.find {|req| req.name == name })}\n\n)
elsif conflict.locked_requirement
o << "\n"
- o << %(Running `bundle update` will rebuild your snapshot from scratch, using only\n)
+ o << %(Deleting your #{name_for_locking_dependency_source} file and running `bundle install` will rebuild your snapshot from scratch, using only\n)
o << %(the gems in your Gemfile, which may resolve the conflict.\n)
elsif !conflict.existing
o << "\n"
diff --git a/spec/bundler/install/gems/flex_spec.rb b/spec/bundler/install/gems/flex_spec.rb
index f9b374cf01..28ffaff3d5 100644
--- a/spec/bundler/install/gems/flex_spec.rb
+++ b/spec/bundler/install/gems/flex_spec.rb
@@ -156,7 +156,7 @@ RSpec.describe "bundle flex_install" do
end
end
- describe "when Gemfile conflicts with lockfile" do
+ describe "when running bundle install and Gemfile conflicts with lockfile" do
before(:each) do
build_repo2
install_gemfile <<-G
@@ -190,7 +190,7 @@ RSpec.describe "bundle flex_install" do
expect(err).to match(/could not find gem 'rack-obama/i)
end
- it "suggests bundle update when the Gemfile requires different versions than the lock" do
+ it "suggests deleting the Gemfile.lock file when the Gemfile requires different versions than the lock" do
bundle "config set force_ruby_platform true"
nice_error = <<-E.strip.gsub(/^ {8}/, "")
@@ -205,7 +205,7 @@ RSpec.describe "bundle flex_install" do
rack_middleware was resolved to 1.0, which depends on
rack (= 0.9.1)
- Running `bundle update` will rebuild your snapshot from scratch, using only
+ Deleting your Gemfile.lock file and running `bundle install` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.
E
@@ -214,6 +214,67 @@ RSpec.describe "bundle flex_install" do
end
end
+ describe "when running bundle update and Gemfile conflicts with lockfile" do
+ before(:each) do
+ build_repo4 do
+ build_gem "jekyll-feed", "0.16.0"
+ build_gem "jekyll-feed", "0.15.1"
+
+ build_gem "github-pages", "226" do |s|
+ s.add_dependency "jekyll-feed", "0.15.1"
+ end
+ end
+
+ install_gemfile <<-G
+ source "#{file_uri_for(gem_repo4)}"
+ gem "jekyll-feed", "~> 0.12"
+ G
+
+ puts lockfile
+ lockfile <<-L
+ GEM
+ remote: #{file_uri_for(gem_repo4)}/
+ specs:
+ jekyll-feed (0.16.0)
+
+ PLATFORMS
+ #{lockfile_platforms}
+
+ DEPENDENCIES
+ jekyll-feed
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
+
+ gemfile <<-G
+ source "#{file_uri_for(gem_repo4)}"
+ gem "github-pages", "~> 226"
+ gem "jekyll-feed", "~> 0.12"
+ G
+ end
+
+ it "suggests deleting the Gemfile.lock file when the Gemfile requires different versions than the lock" do
+ nice_error = <<-E.strip.gsub(/^ {8}/, "")
+ Bundler could not find compatible versions for gem "jekyll-feed":
+ In snapshot (Gemfile.lock):
+ jekyll-feed (>= 0.16.0)
+
+ In Gemfile:
+ jekyll-feed (~> 0.12)
+
+ github-pages (~> 226) was resolved to 226, which depends on
+ jekyll-feed (= 0.15.1)
+
+ Deleting your Gemfile.lock file and running `bundle install` will rebuild your snapshot from scratch, using only
+ the gems in your Gemfile, which may resolve the conflict.
+ E
+
+ bundle :update, :raise_on_error => false
+ expect(err).to end_with(nice_error)
+ end
+ end
+
describe "subtler cases" do
before :each do
install_gemfile <<-G