Skip to content

Conversation

@panozzaj
Copy link

@panozzaj panozzaj commented Jan 2, 2026

What was the end-user or developer problem that led to this PR?

Attempts to implement #7249. I read about this issue in this recent blog post by @tenderlove.

I will admit that I am both new to this repo and that the code was primarily generated with Claude Code. However, I reviewed it (have a lot of Ruby experience) and it seems reasonable. Additionally, I had it write some automated tests and a script to test it out end-to-end. I am hoping this changeset could at least serve as a conversation starter to make sure the requirements are clear, and since it did not take long to implement, I have low attachment to it, so open to feedback.

What is your fix for the problem, implemented in this PR?

Add opt-in support for a global .gem file cache at ~/.cache/gem/gems (respects XDG_CACHE_HOME). This allows sharing cached gems across all Ruby installations and between RubyGems and Bundler.

Enable via:

  • Environment: RUBYGEMS_GLOBAL_GEM_CACHE=true
  • gemrc: global_gem_cache: true
  • Bundler: bundle config set global_gem_cache true

When enabled, RubyGems checks the global cache before downloading and copies downloaded gems to the cache. Bundler's existing global_gem_cache setting now uses the same unified cache location.

Note: #7249 indicates that it's a placeholder for opting everyone in to this behavior for Bundler and Rubygems, but I thought that this might be better for the next version bump since it might have some unexpected behaviors for folks. I think it would be a small code change to make it opt-out, but might be more of a development challenge to do so IMO.

Make sure the following tasks are checked

Add opt-in support for a global .gem file cache at ~/.cache/gem/gems
(respects XDG_CACHE_HOME). This allows sharing cached gems across all
Ruby installations and between RubyGems and Bundler.

Enable via:
- Environment: RUBYGEMS_GLOBAL_GEM_CACHE=true
- gemrc: global_gem_cache: true
- Bundler: bundle config set global_gem_cache true

When enabled, RubyGems checks the global cache before downloading and
copies downloaded gems to the cache. Bundler's existing global_gem_cache
setting now uses the same unified cache location.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant