Skip to content

Commit

Permalink
Use a global bundler cache by default
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez committed Dec 22, 2023
1 parent c0d4244 commit 34f6a65
Show file tree
Hide file tree
Showing 11 changed files with 3 additions and 29 deletions.
1 change: 0 additions & 1 deletion bundler/lib/bundler/feature_flag.rb
Expand Up @@ -32,7 +32,6 @@ def self.settings_method(name, key, &default)
settings_flag(:cache_all) { bundler_3_mode? }
settings_flag(:default_install_uses_path) { bundler_3_mode? }
settings_flag(:forget_cli_options) { bundler_3_mode? }
settings_flag(:global_gem_cache) { bundler_3_mode? }
settings_flag(:path_relative_to_cwd) { bundler_3_mode? }
settings_flag(:plugins) { @bundler_version >= Gem::Version.new("1.14") }
settings_flag(:print_only_version_number) { bundler_3_mode? }
Expand Down
2 changes: 0 additions & 2 deletions bundler/lib/bundler/man/bundle-config.1
Expand Up @@ -141,8 +141,6 @@ The following is a list of all configuration keys and their purpose\. You can le
.IP "\(bu" 4
\fBgemfile\fR (\fBBUNDLE_GEMFILE\fR): The name of the file that bundler should use as the \fBGemfile\fR\. This location of this file also sets the root of the project, which is used to resolve relative paths in the \fBGemfile\fR, among other things\. By default, bundler will search up from the current working directory until it finds a \fBGemfile\fR\.
.IP "\(bu" 4
\fBglobal_gem_cache\fR (\fBBUNDLE_GLOBAL_GEM_CACHE\fR): Whether Bundler should cache all gems globally, rather than locally to the installing Ruby installation\.
.IP "\(bu" 4
\fBignore_funding_requests\fR (\fBBUNDLE_IGNORE_FUNDING_REQUESTS\fR): When set, no funding requests will be printed\.
.IP "\(bu" 4
\fBignore_messages\fR (\fBBUNDLE_IGNORE_MESSAGES\fR): When set, no post install messages will be printed\. To silence a single gem, use dot notation like \fBignore_messages\.httparty true\fR\.
Expand Down
3 changes: 0 additions & 3 deletions bundler/lib/bundler/man/bundle-config.1.ronn
Expand Up @@ -207,9 +207,6 @@ learn more about their operation in [bundle install(1)](bundle-install.1.html).
relative paths in the `Gemfile`, among other things. By default, bundler
will search up from the current working directory until it finds a
`Gemfile`.
* `global_gem_cache` (`BUNDLE_GLOBAL_GEM_CACHE`):
Whether Bundler should cache all gems globally, rather than locally to the
installing Ruby installation.
* `ignore_funding_requests` (`BUNDLE_IGNORE_FUNDING_REQUESTS`):
When set, no funding requests will be printed.
* `ignore_messages` (`BUNDLE_IGNORE_MESSAGES`):
Expand Down
1 change: 0 additions & 1 deletion bundler/lib/bundler/settings.rb
Expand Up @@ -29,7 +29,6 @@ class Settings
gem.coc
gem.mit
git.allow_insecure
global_gem_cache
ignore_messages
init_gems_rb
inline
Expand Down
1 change: 0 additions & 1 deletion bundler/lib/bundler/source.rb
Expand Up @@ -77,7 +77,6 @@ def path?
end

def extension_cache_path(spec)
return unless Bundler.feature_flag.global_gem_cache?
return unless source_slug = extension_cache_slug(spec)
Bundler.user_cache.join(
"extensions", Gem::Platform.local.to_s, Bundler.ruby_scope,
Expand Down
6 changes: 1 addition & 5 deletions bundler/lib/bundler/source/git.rb
Expand Up @@ -227,11 +227,7 @@ def load_spec_files
# across different projects, this cache will be shared.
# When using local git repos, this is set to the local repo.
def cache_path
@cache_path ||= if Bundler.feature_flag.global_gem_cache?
Bundler.user_cache
else
Bundler.bundle_path.join("cache", "bundler")
end.join("git", git_scope)
@cache_path ||= Bundler.user_cache.join("git", git_scope)
end

def app_cache_dirname
Expand Down
1 change: 0 additions & 1 deletion bundler/lib/bundler/source/rubygems.rb
Expand Up @@ -500,7 +500,6 @@ def download_gem(spec, download_cache_path, previous_spec = nil)
# @return [Pathname] The global cache path.
#
def download_cache_path(spec)
return unless Bundler.feature_flag.global_gem_cache?
return unless remote = spec.remote
return unless cache_slug = remote.cache_slug

Expand Down
3 changes: 0 additions & 3 deletions bundler/spec/install/gemfile/git_spec.rb
Expand Up @@ -39,7 +39,6 @@

it "caches the git repo globally and properly uses the cached repo on the next invocation" do
simulate_new_machine
bundle "config set global_gem_cache true"
bundle :install
expect(Dir["#{home}/.bundle/cache/git/foo-1.0-*"]).to have_attributes size: 1

Expand Down Expand Up @@ -334,8 +333,6 @@
it "does not download random non-head refs" do
sys_exec("git update-ref -m \"Bundler Spec!\" refs/bundler/1 main~1", dir: lib_path("foo-1.0"))

bundle "config set global_gem_cache true"

install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
git "#{lib_path("foo-1.0")}" do
Expand Down
6 changes: 1 addition & 5 deletions bundler/spec/install/gems/compact_index_spec.rb
Expand Up @@ -996,11 +996,7 @@ def start
gem "rack"
G

gem_path = if Bundler.feature_flag.global_gem_cache?
default_cache_path.dirname.join("cache", "gems", "localgemserver.test.80.dd34752a738ee965a2a4298dc16db6c5", "rack-1.0.0.gem")
else
default_cache_path.dirname.join("rack-1.0.0.gem")
end
gem_path = default_cache_path.dirname.join("cache", "gems", "localgemserver.test.80.dd34752a738ee965a2a4298dc16db6c5", "rack-1.0.0.gem")

expect(exitstatus).to eq(37)
expect(err).to eq <<~E.strip
Expand Down
2 changes: 0 additions & 2 deletions bundler/spec/install/global_cache_spec.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true

RSpec.describe "global gem caching" do
before { bundle "config set global_gem_cache true" }

describe "using the cross-application user cache" do
let(:source) { "http://localgemserver.test" }
let(:source2) { "http://gemserver.example.org" }
Expand Down
6 changes: 1 addition & 5 deletions bundler/spec/support/path.rb
Expand Up @@ -121,11 +121,7 @@ def default_bundle_path(*path)
end

def default_cache_path(*path)
if Bundler.feature_flag.global_gem_cache?
home(".bundle/cache", *path)
else
default_bundle_path("cache/bundler", *path)
end
home(".bundle/cache", *path)
end

def bundled_app(*path)
Expand Down

0 comments on commit 34f6a65

Please sign in to comment.