New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why does bundler cache gems into local install path? #6102
Comments
When you configure Bundler to use a path relative to your project, the I'm guessing the cache is not as necessary with a local install path, but it's just a cache, things should just work without it. |
Right okay. So I guess the second half of my inquiry was really this: is there a way to either:
|
I don't think you can do either of those right now, no. |
This functionality is missing and should have a sane default, regardless of where bundler is configured to install its gems. For example, Since the remote files aren't likely to change across |
The historical reason this does not exist is because RubyGems had a single "gem path" for both .gem files and for the installed gems. (For example, as if npm used That said, I agree this is a good idea, and it would save both hard drive space and time during future installs. I believe it should probably default to |
I have opened #7249 to track adding such a cache. |
Describe the problem as clearly as you can
When the
path
option is set, bundler puts a cache of all the .gem files into the local install path (e.g.vendor/bundle
) even though they are not needed for deployment.Did you try upgrading rubygems & bundler?
yes (rubygems 3.3.26 and bundler 2.3.26)
Post steps to reproduce the problem
Tested in the official Ruby 3.1.2 Docker library image (
ruby:3.1.2
)Which command did you run?
What were you expecting to happen?
vendor/bundle
contains only the installed gems, not the packaged .gem filesWhat actually happened?
.gem files appear to be cached into
vendor/bundle/ruby/3.1.0/cache/
.After removing them and running some tests they do not appear to be needed for bundler to work correctly. While harmless in principle, they can potentially add a lot of disk usage. This is not ideal when trying to package for deployment (e.g. in a docker container).
I tried various combinations of settings and other tricks:
global_gem_cache
settingBUNDLE_USER_CACHE
environment variabledeployment
settingvendor/cache
andvendor/bundle/ruby/3.1.0/cache/
Is there a way to get rid of this cache other than manually deleting all the .gem files? If bundler needs a cache for downloads that's fine, but it seems like it shouldn't be here.
If not included with the output of your command, run
bundle env
and paste the output belowEnvironment
Bundler Build Metadata
Bundler settings
Gemfile
Gemfile
Gemfile.lock
The text was updated successfully, but these errors were encountered: