Skip to content

Commit 9ad90b2

Browse files
Merge pull request #8975 from rubygems/deivid-rodriguez/cache-all-by-default
Switch `cache_all` to be `true` by default
2 parents 15a9bc5 + 17e356f commit 9ad90b2

File tree

10 files changed

+22
-34
lines changed

10 files changed

+22
-34
lines changed

bundler/lib/bundler/feature_flag.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ def self.settings_method(name, key, &default)
2727

2828
(1..10).each {|v| define_method("bundler_#{v}_mode?") { @major_version >= v } }
2929

30-
settings_flag(:cache_all) { bundler_4_mode? }
3130
settings_flag(:global_gem_cache) { bundler_5_mode? }
3231
settings_flag(:plugins) { @bundler_version >= Gem::Version.new("1.14") }
3332
settings_flag(:update_requires_all_flag) { bundler_5_mode? }

bundler/lib/bundler/settings.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class Settings
8282
"BUNDLE_TIMEOUT" => 10,
8383
"BUNDLE_VERSION" => "lockfile",
8484
"BUNDLE_LOCKFILE_CHECKSUMS" => true,
85+
"BUNDLE_CACHE_ALL" => true,
8586
}.freeze
8687

8788
def initialize(root = nil)

bundler/lib/bundler/source/git.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ def local?
268268
private
269269

270270
def cache_to(custom_path, try_migrate: false)
271-
return unless Bundler.feature_flag.cache_all?
271+
return unless Bundler.settings[:cache_all]
272272

273273
app_cache_path = app_cache_path(custom_path)
274274

bundler/lib/bundler/source/path.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def install(spec, options = {})
8383

8484
def cache(spec, custom_path = nil)
8585
app_cache_path = app_cache_path(custom_path)
86-
return unless Bundler.feature_flag.cache_all?
86+
return unless Bundler.settings[:cache_all]
8787
return if expand(@original_path).to_s.index(root_path.to_s + "/") == 0
8888

8989
unless @original_path.exist?

bundler/spec/cache/git_spec.rb

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@
1313
end
1414

1515
RSpec.describe "bundle cache with git" do
16+
it "does not copy repository to vendor cache when cache_all set to false" do
17+
git = build_git "foo"
18+
ref = git.ref_for("main", 11)
19+
20+
install_gemfile <<-G
21+
source "https://gem.repo1"
22+
gem "foo", :git => '#{lib_path("foo-1.0")}'
23+
G
24+
25+
bundle "config cache_all false"
26+
bundle :cache
27+
expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).not_to exist
28+
29+
expect(the_bundle).to include_gems "foo 1.0"
30+
end
31+
1632
it "copies repository to vendor cache and uses it" do
1733
git = build_git "foo"
1834
ref = git.ref_for("main", 11)
@@ -22,7 +38,6 @@
2238
gem "foo", :git => '#{lib_path("foo-1.0")}'
2339
G
2440

25-
bundle "config set cache_all true"
2641
bundle :cache
2742
expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist
2843
expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.git")).not_to exist
@@ -43,7 +58,6 @@
4358

4459
bundle "config set --local path vendor/bundle"
4560
bundle "install"
46-
bundle "config set cache_all true"
4761
bundle :cache
4862

4963
expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist
@@ -61,7 +75,6 @@
6175
gem "foo", :git => '#{lib_path("foo-1.0")}'
6276
G
6377

64-
bundle "config set cache_all true"
6578
bundle :cache
6679
bundle :cache
6780

@@ -79,7 +92,6 @@
7992
gem "foo", :git => '#{lib_path("foo-1.0")}'
8093
G
8194

82-
bundle "config set cache_all true"
8395
bundle :cache
8496

8597
update_git "foo" do |s|
@@ -109,7 +121,6 @@
109121
gem "foo", :git => '#{lib_path("foo-1.0")}'
110122
G
111123

112-
bundle "config set cache_all true"
113124
bundle :cache
114125

115126
update_git "foo" do |s|
@@ -140,7 +151,6 @@
140151

141152
bundle %(config set local.foo #{lib_path("foo-1.0")})
142153
bundle "install"
143-
bundle "config set cache_all true"
144154
bundle :cache
145155

146156
expect(bundled_app("vendor/cache/foo-invalid-#{ref}")).to exist
@@ -179,7 +189,6 @@
179189
source "https://gem.repo1"
180190
gem "foo", :git => '#{lib_path("foo-1.0")}'
181191
G
182-
bundle "config set cache_all true"
183192
bundle :cache, "all-platforms" => true
184193

185194
pristine_system_gems
@@ -196,7 +205,6 @@
196205
source "https://gem.repo1"
197206
gem "foo", :git => '#{lib_path("foo-1.0")}'
198207
G
199-
bundle "config set cache_all true"
200208
bundle :cache, "all-platforms" => true
201209

202210
pristine_system_gems
@@ -213,7 +221,6 @@
213221
source "https://gem.repo1"
214222
gem "foo", :git => '#{lib_path("foo-1.0")}'
215223
G
216-
bundle "config set cache_all true"
217224
bundle :cache, "all-platforms" => true
218225

219226
pristine_system_gems
@@ -242,7 +249,6 @@
242249
gem "foo", :git => '#{lib_path("foo-1.0")}'
243250
G
244251
bundle "config set global_gem_cache false"
245-
bundle "config set cache_all true"
246252
bundle "config path vendor/bundle"
247253
bundle :install
248254

@@ -274,7 +280,6 @@
274280
gem "foo", :git => '#{lib_path("foo-1.0")}'
275281
G
276282
bundle "config set global_gem_cache false"
277-
bundle "config set cache_all true"
278283
bundle "config path vendor/bundle"
279284
bundle :install
280285

@@ -304,7 +309,6 @@
304309
gem "foo", :git => '#{lib_path("foo-1.0")}'
305310
G
306311
bundle "config set global_gem_cache false"
307-
bundle "config set cache_all true"
308312
bundle "config path vendor/bundle"
309313
bundle :install
310314

@@ -342,7 +346,6 @@
342346
G
343347

344348
ref = git.ref_for("main", 11)
345-
bundle "config set cache_all true"
346349
bundle :cache
347350

348351
expect(bundled_app("vendor/cache/has_submodule-1.0-#{ref}")).to exist
@@ -362,7 +365,6 @@
362365
source "https://gem.repo1"
363366
gem "foo", :git => '#{lib_path("foo-1.0")}'
364367
G
365-
bundle "config set cache_all true"
366368
bundle :cache
367369

368370
ref = git.ref_for("main", 11)
@@ -377,7 +379,6 @@
377379
source "https://gem.repo1"
378380
gem "foo", :git => '#{lib_path("foo-1.0")}'
379381
G
380-
bundle "config set cache_all true"
381382
bundle :cache, "all-platforms" => true, :install => false
382383

383384
pristine_system_gems
@@ -436,7 +437,6 @@
436437
source "https://gem.repo1"
437438
gem "foo", :git => '#{lib_path("foo-1.0")}'
438439
G
439-
bundle "config set cache_all true"
440440

441441
# The algorithm for the cache location for a git checkout is
442442
# in Bundle::Source::Git#cache_path
@@ -498,7 +498,6 @@
498498
end
499499

500500
FileUtils.mkdir_p(bundled_app("vendor/cache"))
501-
bundle "config set cache_all all"
502501

503502
install_gemfile <<-G
504503
source "https://gem.repo1"

bundler/spec/cache/path_spec.rb

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
gem "foo", :path => '#{bundled_app("lib/foo")}'
1010
G
1111

12-
bundle "config set cache_all true"
1312
bundle :cache
1413
expect(bundled_app("vendor/cache/foo-1.0")).not_to exist
1514
expect(the_bundle).to include_gems "foo 1.0"
@@ -23,7 +22,6 @@
2322
gem "foo", :path => '#{lib_path("foo-1.0")}'
2423
G
2524

26-
bundle "config set cache_all true"
2725
bundle :cache
2826
expect(bundled_app("vendor/cache/foo-1.0")).to exist
2927
expect(bundled_app("vendor/cache/foo-1.0/.bundlecache")).to be_file
@@ -42,7 +40,6 @@
4240
gem "#{libname}", :path => '#{libpath}'
4341
G
4442

45-
bundle "config set cache_all true"
4643
bundle :cache
4744
expect(bundled_app("vendor/cache/#{libname}")).to exist
4845
expect(bundled_app("vendor/cache/#{libname}/.bundlecache")).to be_file
@@ -58,7 +55,6 @@
5855
gem "foo", :path => '#{lib_path("foo-1.0")}'
5956
G
6057

61-
bundle "config set cache_all true"
6258
bundle :cache
6359

6460
build_lib "foo" do |s|
@@ -81,7 +77,6 @@
8177
gem "foo", :path => '#{lib_path("foo-1.0")}'
8278
G
8379

84-
bundle "config set cache_all true"
8580
bundle :cache
8681

8782
expect(bundled_app("vendor/cache/foo-1.0")).to exist
@@ -97,20 +92,21 @@
9792
expect(bundled_app("vendor/cache/foo-1.0")).not_to exist
9893
end
9994

100-
it "does not cache path gems by default" do
95+
it "does not cache path gems if cache_all is set to false" do
10196
build_lib "foo"
10297

10398
install_gemfile <<-G
10499
source "https://gem.repo1"
105100
gem "foo", :path => '#{lib_path("foo-1.0")}'
106101
G
102+
bundle "config cache_all false"
107103

108104
bundle :cache
109105
expect(err).to be_empty
110106
expect(bundled_app("vendor/cache/foo-1.0")).not_to exist
111107
end
112108

113-
it "caches path gems by default", bundler: "4" do
109+
it "caches path gems by default" do
114110
build_lib "foo"
115111

116112
install_gemfile <<-G

bundler/spec/install/deploy_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,6 @@
474474
bundle :install
475475
expect(the_bundle).to include_gems "foo 1.0"
476476

477-
bundle "config set cache_all true"
478477
bundle :cache
479478
expect(bundled_app("vendor/cache/foo")).to be_directory
480479

bundler/spec/install/gemfile/specific_platform_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,6 @@
336336
#{Bundler::VERSION}
337337
L
338338

339-
bundle "config set --local cache_all true"
340339
bundle "cache --all-platforms"
341340

342341
expect(err).to be_empty

bundler/spec/lock/lockfile_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,6 @@
786786
c.no_checksum "foo", "1.0"
787787
end
788788

789-
bundle "config set cache_all true"
790789
bundle :cache
791790
bundle :install, local: true
792791

bundler/spec/plugins/source/example_spec.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ def install(spec, opts)
124124
let(:uri_hash) { Digest(:SHA1).hexdigest(lib_path("a-path-gem-1.0").to_s) }
125125
it "copies repository to vendor cache and uses it" do
126126
bundle "install"
127-
bundle "config set cache_all true"
128127
bundle :cache
129128

130129
expect(bundled_app("vendor/cache/a-path-gem-1.0-#{uri_hash}")).to exist
@@ -138,7 +137,6 @@ def install(spec, opts)
138137
it "copies repository to vendor cache and uses it even when installed with `path` configured" do
139138
bundle "config set --local path vendor/bundle"
140139
bundle :install
141-
bundle "config set cache_all true"
142140
bundle :cache
143141

144142
expect(bundled_app("vendor/cache/a-path-gem-1.0-#{uri_hash}")).to exist
@@ -150,7 +148,6 @@ def install(spec, opts)
150148
it "bundler package copies repository to vendor cache" do
151149
bundle "config set --local path vendor/bundle"
152150
bundle :install
153-
bundle "config set cache_all true"
154151
bundle :cache
155152

156153
expect(bundled_app("vendor/cache/a-path-gem-1.0-#{uri_hash}")).to exist
@@ -446,7 +443,6 @@ def installed?
446443
end
447444
G
448445

449-
bundle "config set cache_all true"
450446
bundle :cache
451447
expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist
452448
expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.git")).not_to exist

0 commit comments

Comments
 (0)