Years late, I know, but running sudo su - to log into the root environment (and then running your commands), rather than just running sudo <command> (which runs the command as root, but in your environment), fixed this for me.
sudo su -
sudo <command>