I’m using Zig 0.11.0 and in a build.zig I’m trying to pass the path of the directory containing the zig.h shipped with Zig as include directory to an external tool, i.e. what zig env returns as "lib_dir".
I looked into the source code of the zig env command and found that it uses introspect.zig which does not seem to be part of the standard library.
The std.fs.selfExe[…] family of functions is not what I need here, they refer to the executable that is executing the build (the result of compiling build.zig), somewhere in zig-cache/o/…, not the zig executable itself.
It seems b.zig_exe and then replacing the trailing /zig with /lib is indeed the way to go.