ziglang/zig
259
6.0k
Fork
You've already forked zig
772

fetch packages into project-local directory #31121

Merged
andrewrk merged 8 commits from project-local-deps into master 2026年02月06日 09:41:31 +01:00

closes https://github.com/ziglang/zig/issues/14283

Release Notes

Instead of being fetched into $GLOBAL_ZIG_CACHE/p/$HASH, package dependencies are now fetched into a "zig-pkg" directory relative to the build root (next to build.zig). Users are generally encouraged to not commit these files to source control, however it is understood that some will choose to do so for convenience.

After a package is fetched, the filters are applied (paths field in build.zig.zon) in order to delete files not part of the hash, and then the package is recompressed into a canonical $GLOBAL_ZIG_CACHE/p/$HASH.tar.gz in order to avoid network next time the same package is needed.

The motivation for this change is to make it easier to tinker. Go ahead and edit those files, see what happens. Swap out your package directory with a git clone. Grep your dependencies all together. Configure your IDE to auto-complete based on zig-pkgs directory. Run baobab on your dependency tree. Furthermore, by having the global cache have compressed files instead makes it easier to share that cached data between computers.

zig build will now fail when encountering package dependencies without fingerprint field or with name as a string rather than enum literal. Fingerprint is needed in order to determine that two packages with different versions are intended to be different versions of the same project. It will become an error to have the same fingerprint, same version, different hash in your dependency tree because it means somebody forgot to bump a version number, or somebody is trying to do a hostile package fork and now you have to choose a side.

Zig no longer observes ZIG_BTRFS_WORKAROUND environment variable. The bug has been fixed in upstream Linux a long time ago by now. https://github.com/ziglang/zig/issues/17095

Followup Work

closes https://github.com/ziglang/zig/issues/14283 ## Release Notes Instead of being fetched into `$GLOBAL_ZIG_CACHE/p/$HASH`, package dependencies are now fetched into a "zig-pkg" directory relative to the build root (next to `build.zig`). Users are generally encouraged to not commit these files to source control, however it is understood that some will choose to do so for convenience. After a package is fetched, the filters are applied (`paths` field in `build.zig.zon`) in order to delete files not part of the hash, and then the package is recompressed into a canonical `$GLOBAL_ZIG_CACHE/p/$HASH.tar.gz` in order to avoid network next time the same package is needed. The motivation for this change is to make it easier to tinker. Go ahead and edit those files, see what happens. Swap out your package directory with a git clone. Grep your dependencies all together. Configure your IDE to auto-complete based on zig-pkgs directory. [Run baobab on your dependency tree](https://codeberg.org/awebo-chat/awebo/issues/61). Furthermore, by having the global cache have compressed files instead makes it easier to share that cached data between computers. `zig build` will now fail when encountering package dependencies without `fingerprint` field or with `name` as a string rather than enum literal. Fingerprint is needed in order to determine that two packages with different versions are intended to be different versions of the same project. It will become an error to have the same fingerprint, same version, different hash in your dependency tree because it means somebody forgot to bump a version number, or somebody is trying to do a hostile package fork and now you have to choose a side. Zig no longer observes `ZIG_BTRFS_WORKAROUND` environment variable. The bug has been fixed in upstream Linux a long time ago by now. https://github.com/ziglang/zig/issues/17095 ## Followup Work * https://codeberg.org/ziglang/zig/issues/31139 * when showing package fetching errors, also show dependency trace (which package drags in the package with the error?) * ability to specify name, version, and paths for dependency URLs that do not have a build.zig.zon file inside * https://codeberg.org/ziglang/zig/issues/31124 * https://github.com/ziglang/zig/issues/14288 * https://github.com/ziglang/zig/issues/23236 * a tool for verifying integrity of package directories (detects when the hash does not match the contents)
andrewrk force-pushed project-local-deps from bd432275cf
Some checks failed
ci / aarch64-macos-release (pull_request) Successful in 41m35s
ci / x86_64-freebsd-release (pull_request) Successful in 38m48s
ci / x86_64-netbsd-debug (pull_request) Successful in 46m50s
ci / x86_64-netbsd-release (pull_request) Successful in 38m40s
ci / x86_64-freebsd-debug (pull_request) Successful in 49m59s
ci / x86_64-linux-debug (pull_request) Successful in 53m18s
ci / aarch64-macos-debug (pull_request) Successful in 1h22m22s
ci / aarch64-linux-debug (pull_request) Has been cancelled
ci / powerpc64le-linux-debug (pull_request) Has been cancelled
ci / aarch64-linux-release (pull_request) Has been cancelled
ci / x86_64-linux-release (pull_request) Has been cancelled
ci / x86_64-linux-debug-llvm (pull_request) Has been cancelled
ci / powerpc64le-linux-release (pull_request) Has been cancelled
ci / x86_64-openbsd-debug (pull_request) Has been cancelled
ci / x86_64-windows-debug (pull_request) Has been cancelled
ci / x86_64-openbsd-release (pull_request) Has been cancelled
ci / x86_64-windows-release (pull_request) Has been cancelled
ci / loongarch64-linux-debug (pull_request) Has been cancelled
ci / loongarch64-linux-release (pull_request) Has been cancelled
ci / riscv64-linux-debug (pull_request) Has been cancelled
ci / riscv64-linux-release (pull_request) Has been cancelled
ci / s390x-linux-debug (pull_request) Has been cancelled
ci / s390x-linux-release (pull_request) Has been cancelled
to 6fdd66a336
Some checks failed
ci / x86_64-freebsd-release (pull_request) Successful in 35m24s
ci / x86_64-freebsd-debug (pull_request) Successful in 42m8s
ci / aarch64-macos-release (pull_request) Successful in 47m20s
ci / aarch64-macos-debug (pull_request) Successful in 55m58s
ci / x86_64-netbsd-release (pull_request) Failing after 1h2m32s
ci / x86_64-netbsd-debug (pull_request) Failing after 1h2m36s
ci / x86_64-windows-debug (pull_request) Successful in 54m19s
ci / x86_64-windows-release (pull_request) Successful in 51m1s
ci / x86_64-openbsd-release (pull_request) Successful in 55m7s
ci / x86_64-openbsd-debug (pull_request) Successful in 59m46s
ci / aarch64-linux-release (pull_request) Successful in 1h37m13s
ci / x86_64-linux-debug (pull_request) Successful in 54m46s
ci / aarch64-linux-debug (pull_request) Successful in 2h28m37s
ci / s390x-linux-release (pull_request) Successful in 1h22m15s
ci / powerpc64le-linux-release (pull_request) Successful in 1h42m4s
ci / x86_64-linux-debug-llvm (pull_request) Successful in 2h28m34s
ci / s390x-linux-debug (pull_request) Successful in 2h35m9s
ci / x86_64-linux-release (pull_request) Successful in 2h51m16s
ci / powerpc64le-linux-debug (pull_request) Has been cancelled
ci / loongarch64-linux-debug (pull_request) Has been cancelled
ci / loongarch64-linux-release (pull_request) Has been cancelled
ci / riscv64-linux-debug (pull_request) Has been cancelled
ci / riscv64-linux-release (pull_request) Has been cancelled
2026年02月05日 02:42:46 +01:00
Compare
andrewrk changed title from (削除) make package dependencies local to project (削除ここまで) to package management enhancements 2026年02月05日 02:43:31 +01:00
Contributor
Copy link

Will this zig-pkg directory still be present when you are referencing relative file system paths to dependencies? Not just https/git urls?

Will this ``zig-pkg`` directory still be present when you are referencing relative file system paths to dependencies? Not just https/git urls?
Contributor
Copy link

Package dependencies are now fetched into a "zig-pkg" directory relative to the build root (next to build.zig). Users are generally encouraged to not commit these files to source control, however it is understood that some will choose to do so for convenience.

Could you better express when committing this dir could be sensible?

Say my use-case is that I want to ensure that anybody working with my repo has the full source code of the project (including deps) after cloning it the first time. Would intentionally committing the zig-pkg directory be a supported way to achieve this?

Example: A package manager might want to be able to build everything from source in an offline container, and having the dependencies fetched upfront helps. Another reason might be a concern that some dependencies that the project depends on might be taken down (or face network issues) and it would just be nice to keep a local copy.

This can currently be achieved by picking a directory to copy the dependencies to, and using an explicit path to refer to said dependency. But it doesn't work for nested dependencies (dependencies used by dependencies of the current project) and there's also no idiomatic way to find out what version of the deps that the project is depending on.

Sorry if what I outlined above would better be discussed in a different issue.

> Package dependencies are now fetched into a "zig-pkg" directory relative to the build root (next to build.zig). Users are generally encouraged to not commit these files to source control, however it is understood that some will choose to do so for convenience. Could you better express when committing this dir could be sensible? Say my use-case is that I want to ensure that anybody working with my repo has the full source code of the project (including deps) after cloning it the first time. Would intentionally committing the `zig-pkg` directory be a supported way to achieve this? Example: A package manager might want to be able to build everything from source in an offline container, and having the dependencies fetched upfront helps. Another reason might be a concern that some dependencies that the project depends on might be taken down (or face network issues) and it would just be nice to keep a local copy. This can currently be achieved by picking a directory to copy the dependencies to, and using an explicit path to refer to said dependency. But it doesn't work for nested dependencies (dependencies used by dependencies of the current project) and there's also no idiomatic way to find out what version of the deps that the project is depending on. Sorry if what I outlined above would better be discussed in a different issue.
andrewrk force-pushed project-local-deps from 6fdd66a336
Some checks failed
ci / x86_64-freebsd-release (pull_request) Successful in 35m24s
ci / x86_64-freebsd-debug (pull_request) Successful in 42m8s
ci / aarch64-macos-release (pull_request) Successful in 47m20s
ci / aarch64-macos-debug (pull_request) Successful in 55m58s
ci / x86_64-netbsd-release (pull_request) Failing after 1h2m32s
ci / x86_64-netbsd-debug (pull_request) Failing after 1h2m36s
ci / x86_64-windows-debug (pull_request) Successful in 54m19s
ci / x86_64-windows-release (pull_request) Successful in 51m1s
ci / x86_64-openbsd-release (pull_request) Successful in 55m7s
ci / x86_64-openbsd-debug (pull_request) Successful in 59m46s
ci / aarch64-linux-release (pull_request) Successful in 1h37m13s
ci / x86_64-linux-debug (pull_request) Successful in 54m46s
ci / aarch64-linux-debug (pull_request) Successful in 2h28m37s
ci / s390x-linux-release (pull_request) Successful in 1h22m15s
ci / powerpc64le-linux-release (pull_request) Successful in 1h42m4s
ci / x86_64-linux-debug-llvm (pull_request) Successful in 2h28m34s
ci / s390x-linux-debug (pull_request) Successful in 2h35m9s
ci / x86_64-linux-release (pull_request) Successful in 2h51m16s
ci / powerpc64le-linux-debug (pull_request) Has been cancelled
ci / loongarch64-linux-debug (pull_request) Has been cancelled
ci / loongarch64-linux-release (pull_request) Has been cancelled
ci / riscv64-linux-debug (pull_request) Has been cancelled
ci / riscv64-linux-release (pull_request) Has been cancelled
to 23339a9ad3
Some checks are pending
ci / riscv64-linux-debug (pull_request) Waiting to run
ci / riscv64-linux-release (pull_request) Waiting to run
ci / aarch64-macos-release (pull_request) Successful in 28m39s
ci / x86_64-netbsd-release (pull_request) Successful in 32m14s
ci / x86_64-freebsd-release (pull_request) Successful in 32m7s
ci / x86_64-freebsd-debug (pull_request) Successful in 37m5s
ci / x86_64-netbsd-debug (pull_request) Successful in 39m1s
ci / x86_64-windows-release (pull_request) Successful in 43m34s
ci / x86_64-openbsd-release (pull_request) Successful in 43m47s
ci / x86_64-openbsd-debug (pull_request) Successful in 47m23s
ci / aarch64-macos-debug (pull_request) Successful in 48m0s
ci / x86_64-windows-debug (pull_request) Successful in 51m32s
ci / x86_64-linux-debug (pull_request) Successful in 58m20s
ci / powerpc64le-linux-release (pull_request) Successful in 1h35m18s
ci / x86_64-linux-debug-llvm (pull_request) Successful in 1h37m44s
ci / aarch64-linux-release (pull_request) Successful in 1h39m59s
ci / s390x-linux-release (pull_request) Successful in 1h46m33s
ci / aarch64-linux-debug (pull_request) Successful in 2h18m46s
ci / s390x-linux-debug (pull_request) Successful in 2h40m58s
ci / x86_64-linux-release (pull_request) Successful in 2h42m36s
ci / powerpc64le-linux-debug (pull_request) Successful in 3h30m44s
ci / loongarch64-linux-release (pull_request) Successful in 2h15m28s
ci / loongarch64-linux-debug (pull_request) Waiting to run
2026年02月05日 08:17:07 +01:00
Compare
@ -451,3 +547,2 @@
tryeb.addRootErrorMessage(.{
.msg=tryeb.printString("unable to open global package cache directory '{f}{s}': {s}",.{
cache_root,pkg_sub_path,@errorName(e),
.msg=tryeb.printString("unable to open global package cache directory {f}: {t}",.{
Contributor
Copy link

(削除) global (削除ここまで)

~~global~~
andrewrk marked this conversation as resolved
Contributor
Copy link

Will this zig-pkg directory still be present when you are referencing relative file system paths to dependencies? Not just https/git urls?

It won't be created for dependencies that use relative paths, only for fetched packages

Instead of being fetched into $GLOBAL_ZIG_CACHE/p/$HASH, package dependencies are now fetched into a "zig-pkg" directory relative to the build root (next to build.zig). Users are generally encouraged to not commit these files to source control, however it is understood that some will choose to do so for convenience.

This is the user-facing change: packages will now be stored in ./zig-pkg/pkg-hash relative to the build.zig of your project

After a package is fetched, the filters are applied (paths field in build.zig.zon) in order to delete files not part of the hash, and then the package is recompressed into a canonical $GLOBAL_ZIG_CACHE/p/$HASH.tar.gz in order to avoid network next time the same package is needed.

"delete files" gave me a scare, but this is already the case:
newly downloaded packages are placed into a temporary directory and pruned.
No changes - this is just an implementation details description.

The motivation for this change is to make it easier to tinker. Go ahead and edit those files, see what happens. Swap out your package directory with a git clone. Grep your dependencies all together. Configure your IDE to auto-complete based on zig-pkgs directory. Run baobab on your dependency tree. Furthermore, by having the global cache have compressed files instead makes it easier to share that cached data between computers.

"tinker" is the right term here - browse the codebase, maybe fix a compile error if using a newer nightly that the required. If serious about making any changes one should be using clones and relative paths

Fair and Good:

  • Grep and IDE assisted, no language servers, auto-complete
  • Solves the uses case presented by sagehane

Con:

  • multiple copies of the same package

Edit: Corrections. Just ran it and I was wrong about a few things, apologies.

> Will this zig-pkg directory still be present when you are referencing relative file system paths to dependencies? Not just https/git urls? It won't be created for dependencies that use relative paths, only for fetched packages > Instead of being fetched into $GLOBAL_ZIG_CACHE/p/$HASH, package dependencies are now fetched into a "zig-pkg" directory relative to the build root (next to build.zig). Users are generally encouraged to not commit these files to source control, however it is understood that some will choose to do so for convenience. This is the user-facing change: packages will now be stored in `./zig-pkg/pkg-hash` relative to the build.zig of your project > After a package is fetched, the filters are applied (paths field in build.zig.zon) in order to delete files not part of the hash, and then the package is recompressed into a canonical $GLOBAL_ZIG_CACHE/p/$HASH.tar.gz in order to avoid network next time the same package is needed. "delete files" gave me a scare, but this is already the case: newly downloaded packages are placed into a temporary directory and pruned. No changes - this is just an implementation details description. > The motivation for this change is to make it easier to tinker. Go ahead and edit those files, see what happens. Swap out your package directory with a git clone. Grep your dependencies all together. Configure your IDE to auto-complete based on zig-pkgs directory. Run baobab on your dependency tree. Furthermore, by having the global cache have compressed files instead makes it easier to share that cached data between computers. "tinker" is the right term here - browse the codebase, maybe fix a compile error if using a newer nightly that the required. If serious about making any changes one should be using clones and relative paths Fair and Good: - Grep and IDE assisted, no language servers, auto-complete - Solves the uses case presented by sagehane Con: - multiple copies of the same package Edit: Corrections. Just ran it and I was wrong about a few things, apologies.
Contributor
Copy link

Will it be possible to prefetch dependecies before running 'zig build'?

Will it be possible to prefetch dependecies before running 'zig build'?
Author
Owner
Copy link

Will it be possible to prefetch dependecies before running 'zig build'?

$ zig build --help
...
 --fetch[=mode] Fetch dependency tree (optionally choose laziness) and exit
 needed (Default) Lazy dependencies are fetched as needed
 all Lazy dependencies are always fetched
...

Available since zig 0.12.0. https://github.com/ziglang/zig/issues/14280

> Will it be possible to prefetch dependecies before running 'zig build'? ``` $ zig build --help ... --fetch[=mode] Fetch dependency tree (optionally choose laziness) and exit needed (Default) Lazy dependencies are fetched as needed all Lazy dependencies are always fetched ... ``` Available since zig 0.12.0. https://github.com/ziglang/zig/issues/14280
andrewrk force-pushed project-local-deps from 23339a9ad3
Some checks are pending
ci / riscv64-linux-debug (pull_request) Waiting to run
ci / riscv64-linux-release (pull_request) Waiting to run
ci / aarch64-macos-release (pull_request) Successful in 28m39s
ci / x86_64-netbsd-release (pull_request) Successful in 32m14s
ci / x86_64-freebsd-release (pull_request) Successful in 32m7s
ci / x86_64-freebsd-debug (pull_request) Successful in 37m5s
ci / x86_64-netbsd-debug (pull_request) Successful in 39m1s
ci / x86_64-windows-release (pull_request) Successful in 43m34s
ci / x86_64-openbsd-release (pull_request) Successful in 43m47s
ci / x86_64-openbsd-debug (pull_request) Successful in 47m23s
ci / aarch64-macos-debug (pull_request) Successful in 48m0s
ci / x86_64-windows-debug (pull_request) Successful in 51m32s
ci / x86_64-linux-debug (pull_request) Successful in 58m20s
ci / powerpc64le-linux-release (pull_request) Successful in 1h35m18s
ci / x86_64-linux-debug-llvm (pull_request) Successful in 1h37m44s
ci / aarch64-linux-release (pull_request) Successful in 1h39m59s
ci / s390x-linux-release (pull_request) Successful in 1h46m33s
ci / aarch64-linux-debug (pull_request) Successful in 2h18m46s
ci / s390x-linux-debug (pull_request) Successful in 2h40m58s
ci / x86_64-linux-release (pull_request) Successful in 2h42m36s
ci / powerpc64le-linux-debug (pull_request) Successful in 3h30m44s
ci / loongarch64-linux-release (pull_request) Successful in 2h15m28s
ci / loongarch64-linux-debug (pull_request) Waiting to run
to b089454966
Some checks failed
ci / x86_64-freebsd-release (pull_request) Successful in 43m54s
ci / x86_64-freebsd-debug (pull_request) Has been cancelled
ci / x86_64-openbsd-debug (pull_request) Has been cancelled
ci / aarch64-linux-debug (pull_request) Has been cancelled
ci / aarch64-linux-release (pull_request) Has been cancelled
ci / aarch64-macos-debug (pull_request) Has been cancelled
ci / aarch64-macos-release (pull_request) Has been cancelled
ci / loongarch64-linux-debug (pull_request) Has been cancelled
ci / loongarch64-linux-release (pull_request) Has been cancelled
ci / powerpc64le-linux-debug (pull_request) Has been cancelled
ci / powerpc64le-linux-release (pull_request) Has been cancelled
ci / riscv64-linux-debug (pull_request) Has been cancelled
ci / riscv64-linux-release (pull_request) Has been cancelled
ci / s390x-linux-debug (pull_request) Has been cancelled
ci / s390x-linux-release (pull_request) Has been cancelled
ci / x86_64-linux-debug (pull_request) Has been cancelled
ci / x86_64-linux-debug-llvm (pull_request) Has been cancelled
ci / x86_64-linux-release (pull_request) Has been cancelled
ci / x86_64-netbsd-debug (pull_request) Has been cancelled
ci / x86_64-netbsd-release (pull_request) Has been cancelled
ci / x86_64-openbsd-release (pull_request) Has been cancelled
ci / x86_64-windows-debug (pull_request) Has been cancelled
ci / x86_64-windows-release (pull_request) Has been cancelled
2026年02月06日 01:47:04 +01:00
Compare
andrewrk force-pushed project-local-deps from b089454966
Some checks failed
ci / x86_64-freebsd-release (pull_request) Successful in 43m54s
ci / x86_64-freebsd-debug (pull_request) Has been cancelled
ci / x86_64-openbsd-debug (pull_request) Has been cancelled
ci / aarch64-linux-debug (pull_request) Has been cancelled
ci / aarch64-linux-release (pull_request) Has been cancelled
ci / aarch64-macos-debug (pull_request) Has been cancelled
ci / aarch64-macos-release (pull_request) Has been cancelled
ci / loongarch64-linux-debug (pull_request) Has been cancelled
ci / loongarch64-linux-release (pull_request) Has been cancelled
ci / powerpc64le-linux-debug (pull_request) Has been cancelled
ci / powerpc64le-linux-release (pull_request) Has been cancelled
ci / riscv64-linux-debug (pull_request) Has been cancelled
ci / riscv64-linux-release (pull_request) Has been cancelled
ci / s390x-linux-debug (pull_request) Has been cancelled
ci / s390x-linux-release (pull_request) Has been cancelled
ci / x86_64-linux-debug (pull_request) Has been cancelled
ci / x86_64-linux-debug-llvm (pull_request) Has been cancelled
ci / x86_64-linux-release (pull_request) Has been cancelled
ci / x86_64-netbsd-debug (pull_request) Has been cancelled
ci / x86_64-netbsd-release (pull_request) Has been cancelled
ci / x86_64-openbsd-release (pull_request) Has been cancelled
ci / x86_64-windows-debug (pull_request) Has been cancelled
ci / x86_64-windows-release (pull_request) Has been cancelled
to d8171e8a2e
All checks were successful
ci / x86_64-netbsd-release (pull_request) Successful in 32m17s
ci / x86_64-freebsd-release (pull_request) Successful in 34m1s
ci / x86_64-netbsd-debug (pull_request) Successful in 36m10s
ci / x86_64-freebsd-debug (pull_request) Successful in 40m27s
ci / x86_64-windows-release (pull_request) Successful in 44m6s
ci / aarch64-macos-release (pull_request) Successful in 48m20s
ci / x86_64-windows-debug (pull_request) Successful in 50m21s
ci / aarch64-macos-debug (pull_request) Successful in 58m23s
ci / x86_64-openbsd-debug (pull_request) Successful in 50m32s
ci / x86_64-openbsd-release (pull_request) Successful in 44m36s
ci / aarch64-linux-release (pull_request) Successful in 1h29m54s
ci / x86_64-linux-debug (pull_request) Successful in 46m37s
ci / aarch64-linux-debug (pull_request) Successful in 2h34m47s
ci / s390x-linux-release (pull_request) Successful in 1h16m12s
ci / x86_64-linux-debug-llvm (pull_request) Successful in 2h4m3s
ci / powerpc64le-linux-release (pull_request) Successful in 1h42m41s
ci / x86_64-linux-release (pull_request) Successful in 2h1m43s
ci / s390x-linux-debug (pull_request) Successful in 3h6m36s
ci / powerpc64le-linux-debug (pull_request) Successful in 4h13m52s
ci / loongarch64-linux-release (pull_request) Successful in 2h6m12s
ci / loongarch64-linux-debug (pull_request) Successful in 3h0m30s
ci / riscv64-linux-debug (pull_request) Has been skipped
ci / riscv64-linux-release (pull_request) Has been skipped
2026年02月06日 02:37:08 +01:00
Compare
andrewrk changed title from (削除) package management enhancements (削除ここまで) to fetch packages into project-local directory 2026年02月06日 02:39:44 +01:00
andrewrk deleted branch project-local-deps 2026年02月06日 09:41:33 +01:00
First-time contributor
Copy link

Is there a consideration of falling back to the dep name in build.zig.zon when the packing being used doesn't have a build.zig.zon file? For example when fetching C or other non-standard Zig package.

Currently the path name being used in the following format:

zig-pkg/N-V-__8AANlkNAB77Z946lqp-lgp2qSsOBDADValZC86PhB-
Is there a consideration of falling back to the dep name in build.zig.zon when the packing being used doesn't have a build.zig.zon file? For example when fetching C or other non-standard Zig package. Currently the path name being used in the following format: ``` zig-pkg/N-V-__8AANlkNAB77Z946lqp-lgp2qSsOBDADValZC86PhB- ```
emidoots referenced this pull request from a commit 2026年04月11日 06:55:41 +02:00
Contributor
Copy link

I wonder if it makes sense to do likewise for std? That is, right now I get an error that looks like this:

/Users/matklad/.cache/zig/p/N-V-__8AALEiFxbnKVxP_rPHB849sj7v5YW_fKde4fcxqcBZ/lib/std/debug.zig:420:14: 0x1044e8043 in assert (cst)
 if (!ok) unreachable; // assertion failure
 ^
/Users/matklad/p/csc/csc.zig:112:19: 0x1045edf1b in monotonicity (cst)
 assert(old.header[old_index].view == new.header[new_index].view);

Would be cool if it looked like this instead:

/Users/matklad/p/csc/zig-pkg/std/debug.zig:420:14: 0x1044e8043 in assert (cst)
 if (!ok) unreachable; // assertion failure
 ^
/Users/matklad/p/csc/csc.zig:112:19: 0x1045edf1b in monotonicity (cst)
 assert(old.header[old_index].view == new.header[new_index].view);

I think this will be a tremendous help for people learning to program, having user-friendly access to std like this right from your project's directory, and ability to just go and add debug prints in the middle of std code. Basically, the same tinkering argument.

I wonder if it makes sense to do likewise for `std`? That is, right now I get an error that looks like this: ``` /Users/matklad/.cache/zig/p/N-V-__8AALEiFxbnKVxP_rPHB849sj7v5YW_fKde4fcxqcBZ/lib/std/debug.zig:420:14: 0x1044e8043 in assert (cst) if (!ok) unreachable; // assertion failure ^ /Users/matklad/p/csc/csc.zig:112:19: 0x1045edf1b in monotonicity (cst) assert(old.header[old_index].view == new.header[new_index].view); ``` Would be cool if it looked like this instead: ``` /Users/matklad/p/csc/zig-pkg/std/debug.zig:420:14: 0x1044e8043 in assert (cst) if (!ok) unreachable; // assertion failure ^ /Users/matklad/p/csc/csc.zig:112:19: 0x1045edf1b in monotonicity (cst) assert(old.header[old_index].view == new.header[new_index].view); ``` I think this will be a tremendous help for people learning to program, having user-friendly access to std like this right from your project's directory, and ability to just go and add debug prints in the middle of std code. Basically, the same tinkering argument.
Contributor
Copy link

On the other hand, I would have 17mb of std copied into a large number of projects and that's a lot of wasted disk space for my use case.

On the other hand, I would have ``17mb`` of ``std`` copied into a large number of projects and that's a lot of wasted disk space for my use case.
Sign in to join this conversation.
No reviewers
Labels
Clear labels
abi/f32
abi/ilp32
abi/sf
accepted
This proposal is planned.
arch/21k
arch/6502
arch/aarch64
arch/alpha
arch/amdgcn
arch/arc
arch/arc32
arch/arc64
arch/arm
arch/avr
arch/bfin
arch/bpf
arch/colossus
arch/cris
arch/csky
arch/dlx
arch/epiphany
arch/fr30
arch/frv
arch/hexagon
arch/hppa
arch/hppa64
arch/ia64
arch/kalimba
arch/kvx
arch/lanai
arch/lm32
arch/loongarch32
arch/loongarch64
arch/m32r
arch/m68k
arch/m88k
arch/mcore
arch/microblaze
arch/mips
arch/mips64
arch/mmix
arch/moxie
arch/mrisc32
arch/msp430
arch/nds32
arch/ns32k
arch/nvptx
arch/or1k
arch/powerpc
arch/powerpc64
arch/propeller
arch/riscv32
arch/riscv64
arch/rl78
arch/rx
arch/s390x
arch/sh
arch/sparc
arch/sparc64
arch/spirv
arch/spu
arch/tricore
arch/v850
arch/vax
arch/vc4
arch/ve
arch/wasm
arch/x86
arch/x86_64
arch/xcore
arch/xtensa
autodoc
The web application for interactive documentation and generation of its assets.
backend/c
The C backend outputs C source code.
backend/llvm
The LLVM backend outputs an LLVM bitcode module.
backend/self-hosted
The self-hosted backends produce machine code directly.
binutils
Zig's included binary utilities: zig ar, zig dlltool, zig lib, zig ranlib, zig objcopy, and zig rc.
breaking
Implementing this issue could cause existing code to no longer compile or have different behavior.
build system
The Zig build system - zig build, std.Build, the build runner, and package management.
debug info
An issue related to debug information (e.g. DWARF) produced by the Zig compiler.
docs
An issue with documentation, e.g. the language reference or standard library doc comments.
error message
This issue points out an error message that is unhelpful and should be improved.
frontend
Tokenization, parsing, AstGen, ZonGen, Sema, Legalize, and Liveness.
fuzzing
An issue related to Zig's integrated fuzz testing.
incremental
Reuse of internal compiler state for faster compilation.
lib/c
This issue relates to Zig's libc implementation and/or vendored libcs.
lib/compiler-rt
This issue relates to Zig's compiler-rt library.
lib/cxx
This issue relates to Zig's vendored libc++ and/or libc++abi.
lib/std
This issue relates to Zig's standard library.
lib/tsan
This issue relates to Zig's vendored libtsan.
lib/ubsan-rt
This issue relates to Zig's ubsan-rt library.
lib/unwind
This issue relates to Zig's vendored libunwind.
linking
Zig's integrated object file and incremental linker.
miscompilation
The compiler reports success but produces semantically incorrect code.
os/android
os/contiki
os/dragonfly
os/driverkit
os/emscripten
os/freebsd
os/fuchsia
os/haiku
os/hermit
os/hurd
os/illumos
os/ios
os/linux
os/maccatalyst
os/macos
os/managarm
os/netbsd
os/ohos
os/openbsd
os/plan9
os/redox
os/rtems
os/serenity
os/tvos
os/uefi
os/visionos
os/wasi
os/watchos
os/windows
proposal
This issue suggests language modifications. If it also has the "accepted" label then it is planned.
release notes
This issue or pull request should be mentioned in the release notes.
testing
This issue is related to testing the compiler, standard library, or other parts of Zig.
zig cc
Zig as a drop-in C-family compiler.
zig fmt
The Zig source code formatter.
zig reduce
The Zig source code reduction tool.
bounty
https://ziglang.org/news/announcing-donor-bounties
bug
Observed behavior contradicts documented or intended behavior.
contributor-friendly
This issue is limited in scope and/or knowledge of project internals.
downstream
An issue with a third-party project that uses this project.
enhancement
Solving this issue will likely involve adding new logic or components to the codebase.
infra
An issue related to project infrastructure, e.g. continuous integration.
optimization
A task to improve performance and/or resource usage.
question
No questions on the issue tracker; use a community space instead.
regression
Something that used to work in a previous version stopped working
upstream
An issue with a third-party project that this project uses.
use case
Describes a real use case that is difficult or impossible, but does not propose a solution.
No labels
abi/f32
abi/ilp32
abi/sf
accepted
arch/21k
arch/6502
arch/aarch64
arch/alpha
arch/amdgcn
arch/arc
arch/arc32
arch/arc64
arch/arm
arch/avr
arch/bfin
arch/bpf
arch/colossus
arch/cris
arch/csky
arch/dlx
arch/epiphany
arch/fr30
arch/frv
arch/hexagon
arch/hppa
arch/hppa64
arch/ia64
arch/kalimba
arch/kvx
arch/lanai
arch/lm32
arch/loongarch32
arch/loongarch64
arch/m32r
arch/m68k
arch/m88k
arch/mcore
arch/microblaze
arch/mips
arch/mips64
arch/mmix
arch/moxie
arch/mrisc32
arch/msp430
arch/nds32
arch/ns32k
arch/nvptx
arch/or1k
arch/powerpc
arch/powerpc64
arch/propeller
arch/riscv32
arch/riscv64
arch/rl78
arch/rx
arch/s390x
arch/sh
arch/sparc
arch/sparc64
arch/spirv
arch/spu
arch/tricore
arch/v850
arch/vax
arch/vc4
arch/ve
arch/wasm
arch/x86
arch/x86_64
arch/xcore
arch/xtensa
autodoc
backend/c
backend/llvm
backend/self-hosted
binutils
breaking
build system
debug info
docs
error message
frontend
fuzzing
incremental
lib/c
lib/compiler-rt
lib/cxx
lib/std
lib/tsan
lib/ubsan-rt
lib/unwind
linking
miscompilation
os/android
os/contiki
os/dragonfly
os/driverkit
os/emscripten
os/freebsd
os/fuchsia
os/haiku
os/hermit
os/hurd
os/illumos
os/ios
os/linux
os/maccatalyst
os/macos
os/managarm
os/netbsd
os/ohos
os/openbsd
os/plan9
os/redox
os/rtems
os/serenity
os/tvos
os/uefi
os/visionos
os/wasi
os/watchos
os/windows
proposal
release notes
testing
zig cc
zig fmt
zig reduce
bounty
bug
contributor-friendly
downstream
enhancement
infra
optimization
question
regression
upstream
use case
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
7 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ziglang/zig!31121
Reference in a new issue
ziglang/zig
No description provided.
Delete branch "project-local-deps"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?