How to find unused gems in my Gemfile

Use linux’ file access time to see what’s actually being used.

This requires:

  1. project’s gems isolated in an rvm gemset
  2. gems installed on a partition mounted with the atime (strictatime on ubuntu 12.04) option:

    sudo mount -o remount,strictatime /

  3. complete test coverage (i.e. we’ll be relying on test runs to update file access times)

Note the time and run your tests. Then from your gemdir, do:

ls --time-style long-iso -ltud1 $PWD/*/lib/** | grep "21:44" | sed s/.*gems.// | sed s/.lib.*// | sort -u

Change the 21:44 to whatever time you ran the tests at.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)