at least for linux, it might make sense to containerize the environment and store it. That way next time if it doesn't build on current, one can use the prev that did work.
i use linux on a daily basis and i will say microsoft’s solution to containerization was the .exe
linux has appimage, but containerization also falls prey to gpl.
exe, appimage, containerization are ideologically opposed to the gpl—- errr the other way around. gpl essentially requires compiling from source, which is great, but the intention behind that is to disrupt software supply chain distribution and most people want to be able to upgrade their computer, which is architecturally challenging with gpl, which is where nix, guix and the like can politely solve the compilation and distribution problem
but the core problem is my mom wanted a picture of me to know i’m alive, which is now entirely irrelevant to the topic at hand.