E-xyza / zigler

zig nifs in elixir
MIT License
908 stars 44 forks source link

Error in Livebook #498

Closed ndrean closed 2 weeks ago

ndrean commented 3 weeks ago

In a Livebook (macos, 1.17.3)

Mix.install([{:zigler, "~> 0.13.3"}, {:zig_get, "~> 0.13.1"}])
{"0.14.0-dev.2078+17a87d734", 0} = System.cmd("zig", ["version"])
defmodule Zigit do
  use Zig, otp_app: :zigler

  ~Z"""
    pub fn add_one(number: i64) i64 {
        return number + 1;
    }
  """
end
running command: 
/Users/.../zig-macos-aarch64-0.13.0/zig 
run -lc --dep analyte -Mmain=/.../priv/beam/sema.zig -Merl_nif=/Users/../priv/beam/stub_erl_nif.zig 
--dep erl_nif -Mbeam=/.../priv/beam/beam.zig 
-Mattributes=/var/folders/.../Elixir.Zigit/attributes.zig --dep erl_nif --dep beam --dep attributes -Manalyte=/Users/....Elixir.Zigit.zig

error: main module provided both by '--mod main /Users/...../_build/dev/lib/zigler/priv/beam/sema.zig' 
and by positional argument '.../.Elixir.Zigit.zig'

    (zigler 0.13.3) lib/zig/command.ex:30: Zig.Command.run_zig/2
    (zigler 0.13.3) lib/zig/sema.ex:34: Zig.Sema.run_sema!/1
    (zigler 0.13.3) lib/zig/compiler.ex:150: Zig.Compiler.compile/3
    (zigler 0.13.3) expanding macro: Zig.Compiler.__before_compile__/1
ndrean commented 3 weeks ago

I close this because I reinstalled Livebook and.... it works miraculously.....🤷‍♂️ Thanks for this library.

ndrean commented 3 weeks ago

Nope it's still there.

When I open later the Livebook file in another session, this errors appears again. It could be related to some caching?

ndrean commented 2 weeks ago

So I close it once again. I did not solve this but I think it is a problem with the setup of a Livebook wether you use it as an app or vi the terminal. Zigler has nothing to do with this. Sorry for inconvience.