Just a PSA: the number of gems you have installed on your system will impact your rails boot time. Why is this?
When you require a file, rubygems must find the file. If the file isn't on the load path, it must find it in your installed gems. To do this, it loads all gemspecs and searches for the file. This means all gemspecs on your system are evaluated, so the more gems you have, the longer it takes. You can read more in the rubygems comments.
The second problem is when bundler comes in to the picture. When rubygems loads the gemspec files, it turns them in to
Gem::Specification objects and caches them. Sometimes bundler must modify your
GEM_PATH environment variables. These environment variables tell rubygems where to locate gems on your file system. Unfortunately, if these variables are modified after the specification cache is built, that means the cache must be cleared. Until recently, bundler always cleared the rubygems cache. Since rubygems can load gemspecs before bundler gets activated (or may even while bundler is being activated!), this means it's not unusual for all gemspecs on your system to be evaluated twice. Earlier today, I submitted a patch that will only clear the cache if the environment variables are modified. Hopefully this will mean fewer gemspec evals in the next version of bundler.
To help reduce boot time, just remember:
- Use gemsets (if you're on RVM)
- Clean unused gems often
To clean up your gems, just use the command
Hope that helps!