Try using $HOME instead of ~ to see if that works when running as another user with "sudo -i -u <user>".