System.cmd works in iex, but not in Livebook (using Ghostscript)

I’m trying to use the ghostscript utility from within livebook

If I run this

System.cmd("gs", ["--help"])

I get the error

** (ErlangError) Erlang error: :enoent
    (elixir 1.17.2) lib/system.ex:1114: System.cmd("gs", ["--help"], [])
    #cell:thkhsqcnnih52ci5:15: (file)

However if I run it within IEX then it runs fine.

I’m struggling to debug why it’s failing in Livebook. I tried System.cmd("whoami", []) which works fine in Livebook.

Any help greatly appreciated!

Thanks
Neil

Livebook Desktop starts with a minimal PATH, so you need to add it, such that gs is available.

Create ~/.livebookdesktop.sh and add export PATH=/opt/homebrew/bin:$PATH (or whichever location gs can be found in).

4 Likes

Thanks that solved it!