The Problem was that I needed a feature from the 0.11 version and the latest stable release was 0.10.1.
Since I know a little Python I made myself a program to check on startup if zig has any new version and just install it while replacing the old version.
It maybe is not the finest work of mine but I put in a simple logging feature to be able to debug if anything goes wrong.
Disclaimer (Better safe than sorry):
There is no Backup included
Always be aware of what the code is doing before running other peoples code
This code only checks for master versions.
If zig ever changes the way the json for the versions is formatted the program will probably crash ^^
You will need python 3.x and some pip modules (the most should be installed by default)
Please check your paths!!!
You are responsible if this program deletes something you still needed
I thought maybe some of you will find this helpful so I wanna post it here even though it is not perfect
GitHub gist Link â Automatic Updater for Zig ¡ GitHub
If youâre familiar with the subprocess module in python, you can query zig and get the current install directory. Running âzig envâ on my system produces:
You could then locate the zig_exe field and use the directory from there for your update script. Similarly, you can do things to check for the target platform if you wanted to as well if you wanted to completely automate this.
I will give you one word of caution however - as you can see, I have my installed via snap. The issue is that snap is a package manager and the python script could invalidate any meta-data that the package manager has. This is why I am very cautious of automatic update tools as scripts⌠they donât play nicely with package managers.
Another issue to be careful of is if anything is installed in root directories. This can lead to problems for systems that are not executing the script as root (not a bad problem to have, privilege escalation is quite dangerous).
I can see someone using this if they wanted to provide a config for their system, or if the script prompted the user enter a password. I built a custom C++ object for python a while ago that runs shell scripts because the subprocess library is quite limited in what it can do.
Anyhow, these are just some thoughts, you have to ultimately choose the path that you are most comfortable with.
Yeah thats definitely a nice to have. I have 3 Systems that I want to have implemented with a Script like this. Ubuntu (for a Server), Manjaro and Windows. So more automation is definetly wanted as I get further into Zig development. So this is a point Iâve been thinking about too.
Yep thatâs definitely something to be aware of. I also want to implement some kind of error handling because currently if the installation gets corrupted youâre basically need to re-install it yourself. So yeah not ideal.
I definitely take your points into consideration ^-^
My plan for the future of this project is to convert it from a simple gist to full fletched repo which is a bit more flexible. Features I am currently thinking about is:
automatically detect the system os
backup old files
test new zig installation and maybe notify the user if it is not working (email / desktop notification)
Maybe make it so you could write modules to check for other things
Version handling with optional automatic Path extension (What can go wrong :})
and what ever comes to my mind on my zig journey
If you have any other ideas insert them here
If I can find the time for this and if there are any updates I am happy to share them here.
Not to discourage you, or dissuade you from developing your updater, but just wanted to mention this shell script: https://github.com/jsomedon/night.zig/
It was announced by the developer at r/Zig a couple of weeks before it went down.
I have it on one of my machines and it works nicely.