Skip to content

Support setting ad-hoc version#83

Open
nhawke wants to merge 4 commits into
marler8997:masterfrom
nhawke:ad-hoc-version
Open

Support setting ad-hoc version#83
nhawke wants to merge 4 commits into
marler8997:masterfrom
nhawke:ad-hoc-version

Conversation

@nhawke

@nhawke nhawke commented May 20, 2026

Copy link
Copy Markdown

closes #62

The ad hoc version setting provides a mechanism for running the zig binary outside a project dir without needing to explicitly specify a version. i.e. "zig fmt" instead of "zig 0.15.2 fmt". When inside a project dir, anyzig will still prefer the version specified in the build.zig[.zon] file.

Also adds zig any set-ad-hoc-version command for setting the version. This uses a similar mechanism as the existing 'verbosity' setting for simplicity. Coming up with a more robust configuration system is outside the scope of this change.

Tested manually by going through the various scenarios for version selection (version specified, running init, inside project directory).

The ad hoc version setting provides a mechanism for running the zig
binary outside a project dir without needing to explicitly specify a
version. i.e. "zig fmt" instead of "zig 0.15.2 fmt". When inside a
project dir, anyzig will still prefer the version specified in the
build.zig[.zon] file.

Also adds `zig any set-ad-hoc-version` command for setting the version.
This uses a similar mechanism as the existing 'verbosity' setting for
simplicity. Coming up with a more robust configuration system is outside
the scope of this change.
@nhawke

nhawke commented May 20, 2026

Copy link
Copy Markdown
Author

Just realized that there are tests squirreled away in the build file. Let me look through those and make the necessary changes...

nhawke added 2 commits May 19, 2026 23:19
This test sets the version, which is not hermetic and therefore causes
future test runs to be incorrect. The right way to test this would be to
configure a temporary appdata directory which can be cleaned up after
each test.

For now, the best solution is to just comment the test out.

@marler8997 marler8997 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall looks reasonable, just have 1 change request

Comment thread src/main.zig Outdated
@nhawke nhawke requested a review from marler8997 May 22, 2026 03:46
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.

Set zig version in environment or config

2 participants