Bundler plugin that slims git-installed gems down to the files listed in spec.files, reducing disk usage and cache size.
When you install gems via git: in your Gemfile, Bundler clones the entire repository - including specs, docs, fixtures, CI configs, and other development files that aren't part of the production gem. This bloats your bundle directory and increases Docker image sizes, especially with private gems that have large test suites or documentation.
This plugin automatically removes everything except the files declared in spec.files, giving you the same lean footprint as a gem installed from RubyGems.
Use this if you:
- Install private gems from Git repositories
- Want smaller Docker images and faster deployments
- Have git gems with large test suites, docs, or assets not needed in production
During bundle install, the plugin reports what was removed:
Slimmed my_private_gem 1.2.0 (847 files, 12.3 MB)
The output shows the gem name, version, number of files removed, and total size freed.
- Only affects gems installed from
git "..."sources - Only touches the copy under Bundler's
bundle_path - Never modifies
pathsources or your working copies - Uses
spec.filesas an allow-list; unlisted files are removed - Cleans up empty directories
Add to your Gemfile:
plugin 'bundler-git-slim'
gem 'some_gem', git: 'https://github.com/...'Then run:
bundle installOr install globally:
bundle plugin install bundler-git-slimIf you have git gems already installed, run:
bundle git-slimThis will prune all git-sourced gems in your current bundle.
- Scope limited to
Bundler::Source::Git - Only operates when
spec.full_gem_pathis insideBundler.bundle_path - If
spec.filesis empty or nil, does nothing - Always preserves
*.gemspecfiles
- Ruby >= 3.2
- Bundler >= 2.0 (including Bundler 4.x)
bundle install
bundle exec rake spec
bundle exec rubocop- Fork it
- Create your feature branch (
git checkout -b feature/my-feature) - Commit your changes (
git commit -am 'Add my feature') - Push to the branch (
git push origin feature/my-feature) - Create a Pull Request
MIT