It happened to me because I had to use the templates and document classes provided by my university, which themselves rely on a bunch of packages I wouldn't have installed myself.
My next step was to just try doing the build in containers but I even ran into it there once because I accidentally pulled a newer image...
But it's just anecdotally. Maybe I really was holding it all wrong.