Skip to content

Conversation

@fourlexboehm
Copy link

This adds a check to ~/.config/anyzig/config.zig.zon, or correct platform path to set a default version when none is specified

This is necessary to use anyzig as a normal zig, for tools like cargo zigbuild.

Inspired by a suggestion in #62

This adds a check to ~/.config/anyzig/config.zig.zon, or correct platform path
to set a default version when none is specified
@marler8997
Copy link
Owner

When I first made anyzig I was planning on adding this feature, however, after using it I've since realized that not having a way to set a default encourages projects to be explicit and always keep their version up-to-date by making use of "strategic friction".

There are still many ways to cause zig to point to an explicit version, but they have "more friction". For example you could add the versioned directory to your PATH, or create a zig15 symlink that points to a particular one, or create/add a new directory to PATH with a new zig symlink to a particular version.

Or another idea, I have been wanting to add a subcommand that returns the "executable path", something like zig any exepath, maybe with an optional version argument? If this existed you could use that to add it to your PATH so that running zig will then always resolve to that version in that environment, i.e.

PATH=$(dirname($(zig any exepath 0.15.2)):$PATH zig ...

I'm not familiar with the cargo zigbuild issue, can you expand on that?

@fourlexboehm
Copy link
Author

fourlexboehm commented Dec 22, 2025

cargo zigbuild is a tool for cross compiling Rust projects, it's especially useful in cargo lambda, for deploying AWS lambda Rust functions across environments. It just needs a zig compiler for the cross compilation to work, the version isn't super important as it's not relying on the zig language features, just the C ABI cross compilation. I considered creating a PR for cargo zigbuild to support anyzig, which I think would be the best way to go about it if a default version is an explicit non goal of this project.

I'd rather avoid path shenanigans so the two projects can work ok by default. One work around is to initialise a zig project inside the Rust project dir.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants