Zig package manager issues with the hash of sub-packages

how do i get the correct hash for a package? previously i just let zig paste the hash for me after filling a bad one, but that doesn’t work for the below.

one of my packages is slang-zig, two of its sub-packages hashes are “FIXME”, when i build and run with the package used, it duplicates the package in zig-pkg under the name tmp-…random hash, throwing the same error, `error: invalid hash: short

also, i just noticed, there’s no real documentation for the zig package manager on the learn subsection of the zig website.

Use zig fetch to cache a package and print its hash.

❯ zig fetch --help
Usage: zig fetch [options] <url>
Usage: zig fetch [options] <path>

    Copy a package into the global cache and print its hash.
    <url> must point to one of the following:
      - A git+http / git+https server for the package
      - A tarball file (with or without compression) containing
        package source
      - A git bundle file containing package source

Examples:

  zig fetch --save git+https://example.com/andrewrk/fun-example-tool.git
  zig fetch --save https://example.com/andrewrk/fun-example-tool/archive/refs/heads/master.tar.gz

Options:
  -h, --help                    Print this help and exit
  --global-cache-dir [path]     Override path to global Zig cache directory
  --debug-hash                  Print verbose hash information to stdout
  --save                        Add the fetched package to build.zig.zon
  --save=[name]                 Add the fetched package to build.zig.zon as name
  --save-exact                  Add the fetched package to build.zig.zon, storing the URL verbatim
  --save-exact=[name]           Add the fetched package to build.zig.zon as name, storing the URL verbatim

thanks for the answer, unfortunately putting in the correct hash does not fix the problem.

it does the same thing, duplicating the zig package with the same incorrect “FIXME” hash in its build zon, so i guess its refetching the package

for reference, this is how i add it in my project’s build.zig

    const slang_dep = b.dependency("slang_zig", .{
        .target = target,
        .optimize = optimize,
        // Automatically log any slang diagnostics using `std.log` when providing
        // null as the blob pointer (this is the default)
        .log_diagnostics = .only_for_null,
        // Only use release builds of slang
        .debug_info = false,
    });
    const slang_mod = slang_dep.module("slang");
    exe.root_module.addImport("slang", slang_mod);

and this is how it looks like in my project’s zon


        .slang_zig = .{
            .url = "git+https://github.com/raugl/slang-zig#cf161274b9b7795de6509de94ecbe3d0ae8d1116",

            .hash = "slang_zig-0.0.0-AUGG4QoNBAD-qo1l_xk6pj9dsBP8XniD3IaTyG-5Ya4J",

        },

the problem lies in the package’s zon file, which seems to freak out the package manager and send it into a loop of refetching the same broken package over and over

You are probably going to have to fork the package and update the hashes yourself. Then you will need to change your codebase to use your forked package. It would be great to try and contribute that back to the original. But at least this way you would unblock yourself.