Skip to content

build.zig.zon improve workflow to update dependency hash #16972

@marler8997

Description

@marler8997

Here's my typical process for synchronizing the hash field for a dependency in build.zig.zon:

  1. Set the hash field to a bogus value
  2. Run zig build
  3. Update build.zig.zon with the actual hash displayed in the error message
  4. Run zig build again to verify it worked

My initial proposal is to introduce a special value "?" that tells Zig to update build.zig.zon for us. The new flow becomes.

  1. Set the hash field to "?"
  2. Run zig build to update the hash/verify it works

There have since been other good suggestions:

from @zenMaya: add a command for zig to download and report the hash of a URL (i.e. zig download URL). This might be a good command to make available regardless of whether we need it for this specific use case?

from @mpfaff: put hashes into a separate "lock file" meant to be managed more "automatically" instead of manually. This isn't a full solution but could make other ideas easier.

from @Pyrolistical: add a flag (or maybe a separate command?) that tells zig to update hashes (instead of using a special hash value). I believe this would require zig to assume that all hashes could be invalid meaning it would need to download/recalculate all dependency hashes and update them accordingly, or, zig could maintain a known URL to HASH mapping and only update hashes where this mapping has not been calculated yet. In other words, if the user modifies a URL, zig will see that it hasn't calculated a hash for it yet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSolving this issue will likely involve adding new logic or components to the codebase.zig build systemstd.Build, the build runner, `zig build` subcommand, package management

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions