Fix invalid argument for foreach() in relationships command when offline.

Also removes uncaught exceptions when offline for environment commands.