Fix installing gem from file without dependencies.

Commit 9437ccc fixed the ability to install remote gems that was accidentally
broken by d97fba1, but in the process accidentally broke installing from local
files.

This also changes the order to check for local first, to avoid unnecessary
network requests in the case where the gem is local.

Closes #760.