Cannot call Zig from Livebook

I have Zig installed on OSX via brew and want to use zigler from a Livebook.
It seems that the Livebook does not find Zig.

In a Livebook, I have:

Mix.install([
  {:zigler, "~> 0.13.2"}
])

System.cmd("which", ["elixir"])
#=> {"/Applications/Livebook.app/Contents/Resources/rel/vendor/elixir/bin/elixir\n", 0}

System.cmd("which", ["zig"])
##=> {"", 1}

However, the command line returns:

which elixir
/opt/homebrew/bin/elxiir

which zig
/opt/homebrew/bin/zig

and when I generate an Elixir project (with mix new), it works (System.cmd returns the upper line, and I can run the basic example.

I think this is related to how you’ve installed Livebook. Livebook desktop doesn’t have access to PATH automatically. See this explanation by Jonatan for more info: Livebook Desktop: Why doesn't the default PATH include /usr/local/bin? - #3 by jonatanklosko

Unless I am probably bad at searching through the docs (and the forum), but I didn’t find anything in the docs. So indeed, when I run livebook server from the terminal, I have the correct path. Thanks.

There is some documentation about environment variables and Livebook Desktop here: GitHub - livebook-dev/livebook: Automate code & data workflows with interactive Elixir notebooks

~/.livebookdesktop.sh allows you to set the PATH variable when starting Livebook Desktop.

2 Likes