How to define a step to effectively delete the zig-cache directory?

my clean step definition in build.zig:

        // TODO: can not delete since FileBusy error
        if (b.cache_root.path) |cache_dir| {
            const delete_zig_cache_dir = b.addRemoveDirTree(cache_dir);

but it tell me FileBusy

Builder is an executable in the zig-cache.
Deleting the zig-cache contents, includes the running builder executable.
In Windows you cannot delete a running executable.

See also: 8) Clean zig-out and zig-cache directories

1 Like

As a quick follow up, I usually define a script that I run while I am developing that clears the cache first and then runs zig build (if the project calls for that).

1 Like