diff --git a/bundler/lib/dependabot/bundler/file_updater/lockfile_updater.rb b/bundler/lib/dependabot/bundler/file_updater/lockfile_updater.rb index 57025ee81e..ebd7ebd80f 100644 --- a/bundler/lib/dependabot/bundler/file_updater/lockfile_updater.rb +++ b/bundler/lib/dependabot/bundler/file_updater/lockfile_updater.rb @@ -16,7 +16,6 @@ class LockfileUpdater require_relative "gemspec_updater" require_relative "gemspec_sanitizer" require_relative "gemspec_dependency_name_finder" - require_relative "ruby_requirement_setter" LOCKFILE_ENDING = /(?\s*(?:RUBY VERSION|BUNDLED WITH).*)/m.freeze @@ -80,23 +79,10 @@ def build_updated_lockfile ) end post_process_lockfile(lockfile_body) - rescue SharedHelpers::HelperSubprocessFailed => e - raise unless ruby_lock_error?(e) - - @dont_lock_ruby_version = true - retry - end - - def ruby_lock_error?(error) - return false unless error.error_class == "Bundler::VersionConflict" - return false unless error.message.include?(" for gem \"ruby\0\"") - return false if @dont_lock_ruby_version - - dependency_files.any? { |f| f.name.end_with?(".gemspec") } end def write_temporary_dependency_files - File.write(gemfile.name, prepared_gemfile_content(gemfile)) + File.write(gemfile.name, updated_gemfile_content(gemfile)) File.write(lockfile.name, sanitized_lockfile_body) top_level_gemspecs.each do |gemspec| @@ -236,21 +222,6 @@ def replacement_version_for_gemspec(gemspec_content) end # rubocop:enable Metrics/PerceivedComplexity - def prepared_gemfile_content(file) - content = - GemfileUpdater.new( - dependencies: dependencies, - gemfile: file - ).updated_gemfile_content - return content if @dont_lock_ruby_version - - top_level_gemspecs.each do |gs| - content = RubyRequirementSetter.new(gemspec: gs).rewrite(content) - end - - content - end - def updated_gemfile_content(file) GemfileUpdater.new( dependencies: dependencies, diff --git a/bundler/lib/dependabot/bundler/update_checker/version_resolver.rb b/bundler/lib/dependabot/bundler/update_checker/version_resolver.rb index 9b052acc54..97da366479 100644 --- a/bundler/lib/dependabot/bundler/update_checker/version_resolver.rb +++ b/bundler/lib/dependabot/bundler/update_checker/version_resolver.rb @@ -139,7 +139,8 @@ def error_due_to_restrictive_upper_bound?(error) end def ruby_lock_error?(error) - return false unless error.message.include?(" for gem \"ruby\0\"") + return false unless error.message.include?(" for the Ruby\0 version") || # Bundler 2 + error.message.include?(" for gem \"ruby\0\"") # Bundler 1 return false if @gemspec_ruby_unlocked dependency_files.any? { |f| f.name.end_with?(".gemspec") } diff --git a/bundler/spec/dependabot/bundler/update_checker/version_resolver_spec.rb b/bundler/spec/dependabot/bundler/update_checker/version_resolver_spec.rb index fcb538a9f7..91911d2778 100644 --- a/bundler/spec/dependabot/bundler/update_checker/version_resolver_spec.rb +++ b/bundler/spec/dependabot/bundler/update_checker/version_resolver_spec.rb @@ -462,15 +462,15 @@ to eq(Gem::Version.new("2.0.1")) end - context "that isn't satisfied by the dependencies", :bundler_v2_only do + context "that isn't satisfied by the dependencies" do let(:dependency_files) do bundler_project_dependency_files("imports_gemspec_version_clash_old_required_ruby_no_lockfile") end let(:current_version) { "3.0.1" } - it "raises a DependencyFileNotResolvable error" do - expect { subject }. - to raise_error(Dependabot::DependencyFileNotResolvable) + it "ignores the minimum ruby version in the gemspec" do + expect(resolver.latest_resolvable_version_details[:version]). + to eq(Gem::Version.new("7.2.0")) end end end