Skip to content

Commit

Permalink
fix error when lockfiles are not defined, but ruby version is (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccutrer authored Apr 25, 2024
1 parent e02c96d commit e36db3d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/bundler/multilock/ext/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]) &&
Expand Down
10 changes: 10 additions & 0 deletions spec/bundler/multilock_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e36db3d

Please sign in to comment.