diff --git a/lib/bundler/multilock/ext/dsl.rb b/lib/bundler/multilock/ext/dsl.rb index c83a231..b29ce60 100644 --- a/lib/bundler/multilock/ext/dsl.rb +++ b/lib/bundler/multilock/ext/dsl.rb @@ -20,7 +20,8 @@ def evaluate(gemfile, lockfile, unlock) builder = new builder.eval_gemfile(gemfile, &Multilock.prepare_block) if Multilock.prepare_block builder.eval_gemfile(gemfile) - if (ruby_version_requirement = builder.instance_variable_get(:@ruby_version)) + if (ruby_version_requirement = builder.instance_variable_get(:@ruby_version)) && + Multilock.lockfile_definitions[lockfile] Multilock.lockfile_definitions[lockfile][:ruby_version_requirement] = ruby_version_requirement elsif (parent_lockfile = Multilock.lockfile_definitions.dig(lockfile, :parent)) && (parent_lockfile_definition = Multilock.lockfile_definitions[parent_lockfile]) && diff --git a/spec/bundler/multilock_spec.rb b/spec/bundler/multilock_spec.rb index 774c4d5..1d104b1 100644 --- a/spec/bundler/multilock_spec.rb +++ b/spec/bundler/multilock_spec.rb @@ -934,6 +934,16 @@ end end + it "doesn't error when no lockfiles are defined but ruby version is set" do + with_gemfile(<<~RUBY) do + gem "nokogiri" + + ruby ">= 2.1" + RUBY + invoke_bundler("install") + end + end + private def create_local_gem(name, content = "", subdirectory: true)