From b48d300cd163881b13676e521759e01b9307d102 Mon Sep 17 00:00:00 2001 From: Ashish Kulkarni Date: Mon, 16 Jan 2023 07:34:17 +0000 Subject: [PATCH] only override version when dual-booting Ruby if exact version specified --- lib/bootboot/bundler_patch.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/bootboot/bundler_patch.rb b/lib/bootboot/bundler_patch.rb index f3628c9..5377f20 100644 --- a/lib/bootboot/bundler_patch.rb +++ b/lib/bootboot/bundler_patch.rb @@ -21,7 +21,14 @@ def system # the Gemfile is different from the Ruby version currently running, we # want to write the version specified in `Gemfile` for the current # dependency set to the lock file - Bundler::Definition.build(Bootboot::GEMFILE, nil, false).ruby_version || super + requested_ruby_version = Bundler::Definition.build(Bootboot::GEMFILE, nil, false).ruby_version + if requested_ruby_version + requirement = Gem::Requirement.new(requested_ruby_version.versions) + # unless it's a requirement for an exact ruby version, we can't substitute it + # as there's a range of potential versions, so don't override in that case + requested_ruby_version = nil unless requirement.exact? + end + requested_ruby_version || super else super end