Repository is nil exception fix

The repository is nil check and exception were placed at the wrong location and caused issues
when used inside vagrant with chef solo provisioner.