zig icon indicating copy to clipboard operation
zig copied to clipboard

build: retry when nested lazy dependency causes missing artifact

Open bfredl opened this issue 1 year ago • 0 comments

Consider root build.zig having a mandatory dependency on package A which in turns has a lazy dependency on package B.

When the root build.zig calls

const artifact = dep_a.artifact("a_artifact");

This might cause an error, as package B needs to be fetched before the artifact can be built. However, the hard panic in Dependency.artifact() is seen as a fatal error which prevents the parent zig build process from fetching missing dependencies and trying once more.

Handle this more gracefully by checking if we already know there were missing lazy dependencies, which might come from package A. In the case we still reach a fixed point with a missing artifact, panic as before.

For reference, this happened when depending upon https://github.com/natecraddock/ziglua/blob/486f51d3acc61d805783f5f07aee34c75ab59a25/build.zig and using the ziglua.artifact("lua") artifact before its lazy dependencies were fetched.

bfredl avatar May 23 '24 19:05 bfredl