Zig 0.12 Build with Raylib dependency has path error

Hi, I have a Zig 0.11 project that uses a raylib (C) dependency that is defined in the following ZON file:

    .name = "firefly",
    .version = "0.1.0",

    .dependencies = .{
        .raylib = .{
            .url = "https://github.com/raysan5/raylib/archive/e52ae870f297961b9ac23d2e6eca4937a24ac6c0.tar.gz",
            .hash = "1220b9dc848ba1359453ce8a68fa844bcbc2cacda462b47498f12d3fd932c63390ee",
    .paths = .{

and the specific part in build.zig looks like this:

const exe = b.addExecutable(.{
        .name = "firefly-zig",
        // In this case the main source file is merely a path, however, in more
        // complicated build scripts, this could be a generated file.
        .root_source_file = .{ .path = "src/main.zig" },
        .target = target,
        .optimize = optimize,

    const raylib_dep = b.dependency("raylib", .{
        .target = target,
        .optimize = optimize,

This worked well with Zig version 0.11. Now I updated to version 0.12 and it seems that build generates code still using old API. I get the error:

C:\Users\anhef\AppData\Local\zig\p\1220b9dc848ba1359453ce8a68fa844bcbc2cacda462b47498f12d3fd932c63390ee\src\build.zig:226:23: error: expected type ‘Build.LazyPath’, found ‘*const [12:0]u8’
lib.installHeader(“src/raylib.h”, “raylib.h”);

I already tried to remove cached data from AppData directory, but with no success. It seems that Zig still generates wrong build.zig for the dependency.

Thank you for any help.

Shouldn’t this be something like b.path("src/main.zig") in 0.12?

It seems that the build.zig from dependent Raylib is not compatible with Zig 0.12 anymore and I use to refer to a newer Raylib dependency.
I can see newer versions on Github with newer build.zig but cant figure out the needed hash for that used in the dependency definition.

Anyone an idea?

Either fill the new .url and erase the .hash
or use zig fetch --save to fetch the dependency.

Thanks for the tipp, unfortunately I cannot figure out the new URL, how can I get the URL for the latest raylib build to use here?

Meanwhile I tried to just copy the newest build.zig from raylib repo to local copy and it seems to work. But this is just a temporary workaround.

To construct the url, you visit GitHub - raysan5/raylib: A simple and easy-to-use library to enjoy videogames programming and select the sha of the commit that you want to get. The archive url is: 'https://github.com/raysan5/raylib' + '/archive/' + sha + '.tar.gz'

For the current latest commit:
zig fetch --save https://github.com/raysan5/raylib/archive/4b0e25d3af79ce4c5cd94e8279473764d969cca3.tar.gz


This is working now for me. Just have to go through all the other “var to const” errors now but this should not be a blocker… Thanks for your help!

1 Like