Welcome! Sooner or later think you'd have figured it out.
Happens to me sometimes when updating or upgrading a moodle as the root user of a system. That's why I script updates and upgrades ... so I 'remember' to do things like checking owerships/permissions and setting them correctly.
'spirit of sharing', Ken