Zig Package Gotcha
I ran into a confusing error message in some Zig code today:
./src/board/map.zig:5:14: error: unable to find 'math' const math = @import("math");
I found this very confusing- I'm new to using Zig packages, but I had added all of my project's packages to my build, and my unit tests all built and passed. Why is this particular package called 'math', which is part of this project, now suddenly a problem?
I found the answer here, which explains that you have to not only register your package dependencies, but remember to register the sub-dependencies between packages.
I could see in my command line output from 'zig build' that the 'pkg-begin' and 'pkg-end' entries where in there, but I didn't realize that they needed to specify dependencies as well.
A good example of how to do this in a 'build.zig' file, with a neat trick on how to specify your packages, can be found here. Looking at this article now I see that they even specify a subdependency of 'interface' for their 'lola' package which can be used as an example.