Documentation Index
Fetch the complete documentation index at: https://tally.wharflab.com/llms.txt
Use this file to discover all available pages before exploring further.
bundle install leaves cache directories behind that ship in the final image layer.
| Property | Value |
|---|---|
| Severity | Info (default) / Warning (≥ 80 gems in Gemfile.lock) |
| Category | Performance |
| Default | Enabled |
| Auto-fix | Yes (FixSuggestion) |
Description
Afterbundle install runs, Bundler leaves three cache directories behind that the Rails generator template
explicitly removes:
~/.bundle/— Bundler’s user-level config and runtime cache.${BUNDLE_PATH}/ruby/*/cache— gem.gemarchives that were used to install gems and are no longer needed.${BUNDLE_PATH}/ruby/*/bundler/gems/*/.git— the full git history of any git-sourced gems.
bundle install invocations
ship the caches in the final image.
This rule fires when:
- A Ruby-shaped stage runs
bundle install. - Neither the same RUN nor any later RUN in the same stage performs cleanup of the cache directories.
bundle clean --force (Bundler’s own cleanup mechanism) is recognized as compliant for the cache/
directory.
Suppressions
The rule does NOT fire on:- Builder stages whose layers are not part of the final image (any stage referenced by a later
COPY --from=<stage>is exported, not copied wholesale). - Stages explicitly named
dev,development,test,testing,ci, ordebug. - Non-Ruby stages.
- Windows stages.
Context-aware refinement
When tally is invoked with--context and Gemfile.lock is observable, severity escalates from info to
warning for projects with ≥ 80 resolved gems. The rationale: the absolute size of the leftover cache
scales with the gem count, so projects with large Gemfile.lock files pay a much steeper image-size cost
when this rule fires.
The detail text also names the exact gem count when the lockfile is observable.
Examples
Before
After
The Rails-generator-style fix appends the cleanup to a RUN after the install:bundle clean --force is also accepted:
Auto-fix
The rule offers aFixSuggestion that inserts a new RUN line immediately after the offending bundle install:
FixSuggestion (not FixSafe) because the canonical paths assume BUNDLE_PATH follows the Rails
generator’s default placement. Projects with custom BUNDLE_PATH values may need to adjust the paths after
applying the fix.
References
- Rails Dockerfile generator template —
performs the canonical cleanup after
bundle install. - Bundler
bundle cleandocumentation — Bundler’s own cleanup mechanism for thecache/directory.