Default to Gem.dir as late as possible.
Don't alter Gem::Specification.dirs during install

This makes RubyGems easier to use when installing gems via the API.  The
commits to switch from DependencyInstaller to DependencyResolver for
resolution broke this patch, so this is a reimplementation.

Based on Pull Request #452