Why System.cmd produce error at runtime, but works in iex?

How is the instance started that doesn’t work?

Is it perhaps started in an environment that has a shorter PATH with less entries and ngspice is not visible for it?

Check System.get_env("PATH") and compare the results.