You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature Request] A "prune" option, or similar. #3266
In some situations, (such as docker image building, CI caching, etc), it's desirable to minimize the bundler path footprint.
Current workaround
Here's the script we're using right now:
#!/bin/bashset -eo pipefail
bundler_root=/tmp/bundle
echo"Cache size before pruning:"
du -sh ${bundler_root}# Another cache; no value once all gems are installed
rm -rf ${bundler_root}/ruby/*/cache
# git dirs of installed gems are useless once we no longer have to update them
rm -rf ${bundler_root}/ruby/*/bundler/gems/*/.git
find ${bundler_root} -type f \( \
-iname '*.a' \
-o -iname '*.o' \
-o -iname '*.h' \
-o -iname '*.c' \
-o -iname '*.d' \
-o -iname '*.hpp' \
-o -iname '*.cpp' \
\) -print0 | xargs -0 -n 100 rm -f
echo"Cache size after pruning:"
du -sh ${bundler_root}
And it's quite effective:
Cache size before pruning:
1.7G /tmp/bundle
Cache size after pruning:
800M /tmp/bundle
Proposal
This script works well, but I think that if such feature was shipped with bundler itself it would be useful for many more people.
NB: the .a/o/etc removal is probably out of scope for a generic tool, but I think the cache and .git would benefit most people without breaking anything.
Activity