summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2025-11-28 16:57:15 +0900
committergit <svn-admin@ruby-lang.org>2025-11-28 22:50:49 +0000
commitbb2e4d58cce135d3609dba1ee17ed614522a88bf (patch)
tree55a8ca0f7f7dadc2e5763e0135a9423713052ca7
parent7bd80e7e3e3dbb724616c038e6e0944128d6f905 (diff)
[ruby/rubygems] Fixed checksums generation issue when no source is specified
https://github.com/ruby/rubygems/commit/bb4d791cb4
-rw-r--r--lib/bundler/definition.rb2
-rw-r--r--spec/bundler/commands/lock_spec.rb50
2 files changed, 52 insertions, 0 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 437390f3ec..2fa7d0d277 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -539,6 +539,8 @@ module Bundler
end
def add_checksums
+ require "rubygems/package"
+
@locked_checksums = true
setup_domain!(add_checksums: true)
diff --git a/spec/bundler/commands/lock_spec.rb b/spec/bundler/commands/lock_spec.rb
index ab1926734c..c8af9c8dd4 100644
--- a/spec/bundler/commands/lock_spec.rb
+++ b/spec/bundler/commands/lock_spec.rb
@@ -2035,6 +2035,56 @@ RSpec.describe "bundle lock" do
L
end
+ it "adds checksums when source is not specified" do
+ system_gems(%w[myrack-1.0.0], path: default_bundle_path)
+
+ gemfile <<-G
+ gem "myrack"
+ G
+
+ lockfile <<~L
+ GEM
+ specs:
+ myrack (1.0.0)
+
+ PLATFORMS
+ ruby
+ x86_64-linux
+
+ DEPENDENCIES
+ myrack
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
+
+ simulate_platform "x86_64-linux" do
+ bundle "lock --add-checksums"
+ end
+
+ # myrack is coming from gem_repo1
+ # but it's simulated to install in the system gems path
+ checksums = checksums_section do |c|
+ c.checksum gem_repo1, "myrack", "1.0.0"
+ end
+
+ expect(lockfile).to eq <<~L
+ GEM
+ specs:
+ myrack (1.0.0)
+
+ PLATFORMS
+ ruby
+ x86_64-linux
+
+ DEPENDENCIES
+ myrack
+ #{checksums}
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
+ end
+
it "adds checksums to an existing lockfile, when gems are already installed" do
build_repo4 do
build_gem "nokogiri", "1.14.2"