summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2025-08-13 19:36:21 +0200
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2025-09-03 23:38:37 +0900
commit2558350c0488ccd1a71b5f1e86f7fdbccad5056e (patch)
treec1ab1c39b7bafab29218cf9fa6c6ffc0f982807c
parent7488b48a76af7359ea121f42db12b12d6b439b0d (diff)
[rubygems/rubygems] Fix `bundle cache` failing in frozen mode if vendor/cache is empty
https://github.com/rubygems/rubygems/commit/36c5af9156
-rw-r--r--lib/bundler/cli/install.rb2
-rw-r--r--lib/bundler/definition.rb6
-rw-r--r--spec/bundler/commands/cache_spec.rb29
3 files changed, 33 insertions, 4 deletions
diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb
index 074afd64eb..5eeba0c8d8 100644
--- a/lib/bundler/cli/install.rb
+++ b/lib/bundler/cli/install.rb
@@ -42,8 +42,6 @@ module Bundler
"before deploying."
end
- options[:local] = true if Bundler.app_cache.exist?
-
Bundler.settings.set_command_option :deployment, true if options[:deployment]
Bundler.settings.set_command_option :frozen, true if options[:frozen]
end
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 6cbaa9c396..e400c38cec 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -189,12 +189,14 @@ module Bundler
def setup_domain!(options = {})
prefer_local! if options[:"prefer-local"]
+ sources.cached!
+
if options[:add_checksums] || (!options[:local] && install_needed?)
- remotely!
+ sources.remote!
true
else
Bundler.settings.set_command_option(:jobs, 1) unless install_needed? # to avoid the overhead of Bundler::Worker
- with_cache!
+ sources.local!
false
end
end
diff --git a/spec/bundler/commands/cache_spec.rb b/spec/bundler/commands/cache_spec.rb
index db5ec9cf21..fd8d0381c9 100644
--- a/spec/bundler/commands/cache_spec.rb
+++ b/spec/bundler/commands/cache_spec.rb
@@ -326,6 +326,35 @@ RSpec.describe "bundle cache" do
bundle "env"
expect(out).to include("frozen")
end
+
+ it "caches gems without installing when lockfile is in sync, and --no-install is passed, even if vendor/cache directory is initially empty" do
+ gemfile <<-G
+ source "https://gem.repo1"
+ gem "myrack"
+ G
+ lockfile <<-L
+ GEM
+ remote: https://gem.repo1/
+ specs:
+ myrack (1.0.0)
+
+ PLATFORMS
+ #{lockfile_platforms}
+
+ DEPENDENCIES
+ myrack
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
+ app_cache = bundled_app("vendor/cache")
+ FileUtils.mkdir_p app_cache
+
+ bundle "cache --no-install"
+ expect(out).not_to include("Installing myrack 1.0.0")
+ expect(out).to include("Fetching myrack 1.0.0")
+ expect(app_cache.join("myrack-1.0.0.gem")).to exist
+ end
end
context "with gems with extensions" do