Zig init error

I just installed zig (version 0.12.0-dev.2565+9bf97b849). I have put the zig executable in /usr/bin . When I run zig init, I get this error:

~/test_zig $ zig init
error: unable to find zig installation directory: FileNotFound

What did I do wrong?
I initially had put zig binary in ~/.local/bin/

1 Like

sorry to ask stupid question but have you added it to the path, in anycase you should try zigup on github, I use it to install and manage version of the compiler. It does all of the installation and symlink for you

I figured out what I did wrong. I only move the executable zig when I need to move the whole zig folder with the lib folder inside to final location.

1 Like

I do not think it is a good idea. Better to put everything into, say, /opt:

$ ls -1 /opt/

In my ~/.profile I have these lines in the end:

if [ -d $ZIGDIR ] ; then

So if I want to use current release, I type just zig ... and if I want to use some other version, I type the full path, i.e /opt/zig-0.12/zig ....

Maybe a more convenient way is to keep your extracted Zig download in you home directory somewhere and then just symlink the zig binary to /usr/local/bin.

$ cd /usr/local/bin
$ ln -s <path to Zig extracted dir>/zig zig

/usr/local/bin will be on any Unix / Linux system’s path.

1 Like