Fix bug with fetch when using sudo: true

Fixes #3111