asdf is a good general tool version management tool. Just like virtualenv
for python
, or rvm
for Ruby
, or nvm
for nodejs
. It supports plugins so it can be used as a one tool to rule all languages thing. So I was attempted to use it to manage my local zig
version.
Then I found asdf-zig
from asdf-community/asdf-zig, and it works, and works great! Until that I found as zig
envolves fast, seems every important project is using their own specific dev version like 0.12.0-dev.2139+e025ad7b4
or 0.12.0-dev.1828+225fe6ddb
, they are unfortunately not supported by asdf-zig
.
But I do want to use this tool for managing my local zig
versions, so again, seems the code of asdf-zig
is simple enough, so I forked and created my own flavor, where I put it at https://github.com/liyu1981/asdf-zig.
Simply to say, it allows to create a custom version file at ~/.asdf/custom/zig/versions.json
like below
{
"0.12.0-dev.2139+e025ad7b4": {},
"0.12.0-dev.1828+225fe6ddb": {},
}
then normal asdf list-all zig
can show these versions and asdf install zig 0.12.0-dev.2139+e025ad7b4
can install it and then use it as it supports natively.
Following pictures shows how it is used
a fork of asdf-zig
for supporting custom versions
why
The official asdf-zig
can only support what versions are listed at https://ziglang.org/download/index.json
, which are all versions either official or cutting-edge master. But as we know zig
is evolving fast, sometime I need to stick with a specific version for a while, like 0.12.0-dev.2139+e025ad7b4
. This is easy job if just download it and make it available to my path. But if there are multiple projects using different custom zig version, manual changing will be tedious.
So I start to miss asdf
, the one shop for managing many different new language runtimes, and luckily there is asdf-zig
, but unluckily it supports no custom versions.
So I just make my fork and adjust it a bit for my usage.
how it works
essentially my fork replaces the official asdf-zig
. To install it, need to remove the old one, just
Update:
added the ability to use zig master
version as @justinryanh commented.
Top comments (4)
Nice. I've been just doing the latest master but that's great. Good post
a ha, I get you, a good missing point, and I updated my fork with a solution to that :)
can you add support for zls in your fork and does your fork work with mise ?
You got me, I do not know mise yet, so I do not know whether it will work or not.
For support for zls I am bit of not getting the point. As I am using this in vscode, zls installed by vscode extension is working with asdf installed zig version.
Anyway, I am happy to learn from you the usage. If zls has a similar release manifesto file like zig: ziglang.org/download/index.json, it will not be hard to add the support.