BUNDLE-CACHE(1)
π BUNDLE-CACHE β the manual, but make it make sense
okay so bestie, you're looking at bundle-cache(1) from the General Commands Manual, and honestly? this one's a little gem (pun fully intended π). let's get into it.
β¨ NAME β¨
bundle-cache β package your needed .gem files into your application. that's it, that's the vibe. you're basically packing a little survival kit of gems and tucking it into your app so future-you never has to panic-download anything again π
π¦ SYNOPSIS π¦
bundle cache [OPTIONS]
and the aliases, because bundler loves a nickname era:
alias: package, pack
so bundle package and bundle pack are literally the same thing. iykyk π
π DESCRIPTION π
so what this does: it copies all of the .gem files you need to actually run the application into the vendor/cache directory. adorable, right?
and then in the future, when you run bundle install(1) bundle-install.1.html, it'll use the gems sitting in that cache in preference to the ones on rubygems.org. like, it checks its own purse before going shopping. iconic behavior tbh π«Ά
πΈ OPTIONS πΈ
--all-platformsβ includes gems for all platforms present in the lockfile, not just the current one. so you're not just packing for yourself, you're packing for the whole group chat β¨--cache-path=CACHE-PATHβ wanna put the cache somewhere other than the defaultvendor/cache? this is how. specify a different cache path, no cap.--gemfile=GEMFILEβ use the gemfile you specify instead ofGemfile. for when your gemfile has a whole other name and identity, main character energy.--no-installβ don't install the gems, just update the cache. cache only, no extra steps π--quietβ only output warnings and errors. silence, but make it useful π€«
π§ GIT AND PATH GEMS π§
plot twist: bundle cache can also package :git and :path dependencies, not just .gem files. so it's not just a gem-cacher, it's a whole dependency-cacher.
you can turn this off by setting cache_all to false. your call, bestie.
π SUPPORT FOR MULTIPLE PLATFORMS π
okay so this is the part where it gets a little technical but stay with me π
when you're using gems that have different packages for different platforms, Bundler supports caching gems for other platforms β but only where the Gemfile has been resolved (i.e. present in the lockfile) β into vendor/cache.
this needs to be enabled via the --all-platforms option. and here's the cute part: this setting will be remembered in your local bundler configuration. it's giving "set it and forget it" π
π₯ REMOTE FETCHING π₯
okay so by default, if you run bundle install(1) bundle-install.1.html after running bundle cache(1) bundle-cache.1.html, bundler will still connect to rubygems.org to check whether a platform-specific gem exists for any of the gems in vendor/cache. yes, even though you literally just cached them. it's thorough like that π
for instance, consider this Gemfile(5):
source "https://rubygems.org"
gem "nokogiri"
so if you run bundle cache under C Ruby, bundler will retrieve the version of nokogiri for the "ruby" platform. but if you deploy to JRuby and run bundle install, bundler is forced to check whether a "java" platformed nokogiri exists.
and like β even though the nokogiri gem for the Ruby platform is technically acceptable on JRuby, it has a C extension that does not run on JRuby. so as a result, bundler will, by default, still connect to rubygems.org to check whether it has a version of one of your gems more specific to your platform. rude? maybe. correct? yes π
and this problem is also not limited to the "java" platform. a similar (common) problem can happen when you're developing on Windows and deploying to Linux, or even when developing on OSX and deploying to Linux. so yeah, it's a whole situation.
so here's the move: if you know for sure that the gems packaged invendor/cacheare appropriate for the platform you're on, you can runbundle install --localto skip checking for more appropriate gems, and use the ones invendor/cache. go off, no notes π
one way to be sure that you have the right platformed versions of all your gems is to run bundle cache on an identical machine and check in the gems. for instance, you can run bundle cache on an identical staging box during your staging process, and check in the vendor/cache before deploying to production. staging exists for a reason, bestie π
and one more thing: by default, bundle cache(1) bundle-cache.1.html fetches and also installs the gems to the default location. but if you want to package the dependencies to vendor/cache without installing them to the local install location, you can run:
bundle cache --no-install
look at you, being all intentional about it β¨
β HISTORY β
a little lore for you: in Bundler 2.1, cache took in the functionalities of package, and now package and pack are aliases of cache. so if you were around in the before-times, that's where your old muscle memory went π¦
okay that's the whole page, bestie β you're officially caught up π this was BUNDLE-CACHE(1) from the General Commands Manual, dated April 2026. go cache those gems and slay ππ
β¨
π¦ where this page comes from
- centos-stream 10: ruby4.0 4.0.6-37.el10 Β· (Ruby OR BSD-2-Clause) AND (Ruby OR BSD-2-Clause OR GPL-1.0-or-later) AND BSD-3-Clause AND (GPL-3.0-or-later WITH Bison-exception-2.2) AND ISC AND LicenseRef-Fedora-Public-Domain AND MIT AND CC0-1.0 AND zlib AND Unicode-DFS-2015 AND HPND-Markus-Kuhn AND Ruby-pty AND (Ruby OR BSD-2-Clause OR Python-2.0.1) AND BSD-2-Clause AND (Apache-2.0 OR BSL-1.0) AND GPL-2.0-only AND CC-BY-2.5 AND OFL-1.1-RFN AND BSL-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms