ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
33.67k stars 2.47k forks source link

clarify error: "unable to find zig installation directory: FileNotFound" #17249

Open godalming123 opened 11 months ago

godalming123 commented 11 months ago

Zig Version

0.12.0-dev.494+a8d2ed806

Steps to Reproduce and Observed Output

  1. Download the latest nightly .tar.xz file binary for linux
  2. Copy the zig binary from that tarball to /bin/
  3. Attempt to run it in a terminal
  4. Witness the errror

Expected Output

The error should describe what you need to put where, something like: "Please place the lib directory from the zig extracted source code into /bin" (Or replace /bin with wherever that directory is recommended to go to fix the error - I could make it work by copying all the files in it to /lib)

slonik-az commented 11 months ago

The following worked for me OK:

  1. Unpack the tar file somewhere.
  2. symlink the zig executable to a bin/ directory in my path.
godalming123 commented 11 months ago

I can get zig to work fine, it's just that this is not the best error message for new users

squeek502 commented 11 months ago

The relevant information is in the GitHub readme:

A Zig installation is composed of two things:

  1. The Zig executable
  2. The lib/ directory

At runtime, the executable searches up the file system for the lib/ directory, relative to itself:

  • lib/
  • lib/zig/
  • ../lib/
  • ../lib/zig/
  • (and so on)

In other words, you can unpack a release of Zig anywhere, and then begin using it immediately. There is no need to install it globally, although this mechanism supports that use case too (i.e. /usr/bin/zig and /usr/lib/zig/).

The 'Getting started' section of the website doesn't have the same level of detail:

Direct download

This is the most straight-forward way of obtaining Zig: grab a Zig bundle for your platform from the Downloads page, extract it in a directory and add it to your PATH to be able to call zig from any location.

nathany commented 11 months ago

Also ran into this FileNotFound error when building from source and then copying the binary to my ~/bin folder on macOS.

This produces stage3/bin/zig which is the Zig compiler built by itself. https://github.com/ziglang/zig/wiki/Building-Zig-From-Source#for-macos--homebrew

Copying the stage3/lib folder over got it working. Agreed that the error message could be better. Thanks.

timblaktu commented 4 months ago

Same as @nathany here, after building from source on Debian and using /usr/local instead of ~/, I had to sudo cp -ar build/stage3/lib/zig /usr/local/lib/ as well as sudo cp -a build/stage3/bin/zig /usr/local/bin/. I added some language in the "build from source" wiki page to describe the need to copy the lib folder as well as the zig compiler binary onto your path.