Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Script that finds out the ruby versions used in subdirectories, to help you reclaim disk space.
# cd src
# wget
# chmod +x
# ./
for F in *; do
[[ ! -d "$F" ]] && continue
unset V
if [[ -n "`find "$F" -maxdepth 1 -type f -name *.gemspec`" ]]; then
# echo Skipping gem $F
elif [[ -f "$F/.ruby-version" ]]; then
V=`cat "$F/.ruby-version"`
elif [[ -f "$F/Gemfile" ]]; then
V=`cat "$F/Gemfile" | egrep "ruby [\"\'][0-9\.]+[\'\"]" | sed -e "s/ruby [\'\"]//" -e "s/[\'\"]//"`
[[ -z "$V" ]] && continue
printf "%25s: %s\n" "$F" "$V"
if [[ -d "$F/vendor/bundle" ]]; then
echo You have a vendor/bundle directory here, are you sure you need it?
echo If you remove it, remember to remove .bundle/config too!
du -hs "$F/vendor/bundle"
echo Ruby versions in ~/.rbenv/versions/:
(cd ~/.rbenv/versions/ && du -chs *)
echo To uninstall a ruby version:
echo rbenv uninstall 2.1.2
echo To clean up gems:
echo Go to one app and run:
echo 'bundle clean --force'
echo Then go to the rest and simply run: bundle
echo Logfiles larger than 10M:
find . -iname *.log -size +10M -exec du -h {} \;
echo To clear out your logs, run one of these:
echo 'for d in *; do ([[ -f "$d/Gemfile" ]] && echo "$d" && cd "$d" && bundle exec rake log:clear &> /dev/null); done'
echo 'find . -iname *.log -size +10M | xargs rm'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
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.