Handle cases where _gem() returns False

This prevents a traceback when _gem() returns False due to a problem
running the gem command. Fixes #5886.