Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange behaviour referecing wrong module when trying to start binary #117

Closed
zoedsoupe opened this issue Oct 30, 2023 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@zoedsoupe
Copy link

zoedsoupe commented Oct 30, 2023

Host

Host OS: MacOS Sonoma 14.1
Host CPU: arm64

Please run zig version in your Burrito project directory and write the version here: v0.11.0

Please run elixir -v in your Burrito project directory and write the version here:

Erlang/OTP 26 [erts-14.1.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]

Elixir 1.14.5 (compiled with Erlang/OTP 26)

Target

Host OS: MacOS 14.1
Host CPU: arm64
Host LibC and Version

Apple clang version 15.0.0 (clang-1500.0.40.1)
Target: arm64-apple-darwin23.0.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Nice project here! I trying to build a simple CLI with burrito but it seems to be referencing the wrong start module. I don’t know if I’m doing something wrong… This is my application module (entrypoint):

# lib/exlings/application.ex
defmodule Exlings.Application do
  @moduledoc """
  Main application entrypoint to parse args
  and handle commands.
  """

  use Application

  alias Burrito.Util.Args

  @impl true
  def start(_, _) do
    IO.puts("FUNCIONANDO")
    args = Args.get_arguments()
    IO.puts(args)

    Exlings.CLI.parse(args)

    System.halt(0)
  end
end

And the initial module Exlings there’s no content besides a @moduledoc.

Trying to build and run it gives me this error:

08:22:11.188 [notice] Application exlings exited: exited in: Exlings.start(:normal, [])
    ** (EXIT) an exception was raised:
        ** (UndefinedFunctionError) function Exlings.start/2 is undefined or private
            (exlings 0.1.0) Exlings.start(:normal, [])
            (kernel 9.1) application_master.erl:293: :application_master.start_it_old/4
Kernel pid terminated (application_controller) ("{application_start_failure,exlings,{bad_return,{{'Elixir.Exlings',start,[normal,[]]},{'EXIT',{undef,[{'Elixir.Exlings',start,[normal,[]],[]},{application_master,start_it_old,4,[{file,\"application_master.erl\"},{line,293}]}]}}}}}")

Trying to move this implementation to the main module Exlings seems to raise the same not found function error.

My mix.exs is:

defmodule Exlings.MixProject do
  use Mix.Project

  def project do
    [
      app: :exlings,
      version: "0.1.0",
      elixir: "~> 1.14",
      start_permanent: Mix.env() == :prod,
      deps: deps(),
      releases: releases()
    ]
  end

  def application do
    [
      mod: {Exlings.Application, []},
      extra_applications: [:logger]
    ]
  end

  def releases do
    [
      exlings: [
        steps: [:assemble, &Burrito.wrap/1],
        cookie: Base.url_encode64(:crypto.strong_rand_bytes(40)),
        burrito: [
          targets: [
            macos: [os: :darwin, cpu: :x86_64],
            macos_m1: [os: :darwin, cpu: :aarch64],
            linux: [os: :linux, cpu: :x86_64],
            windows: [os: :windows, cpu: :x86_64]
          ],
          debug: Mix.env() != :prod
        ]
      ]
    ] 
  end

  defp deps do
    [
      {:owl, "~> 0.6"},
      {:nexus_cli, "~> 0.4.2"},
      {:file_system, "~> 0.2 or ~> 0.3"},
      {:burrito, github: "burrito-elixir/burrito"},
      {:credo, "~> 1.6", only: [:dev, :test], runtime: false}
    ]
  end
end

The complete project can be found in https://github.com/zoedsoupe/exlings

@zoedsoupe zoedsoupe added the bug Something isn't working label Oct 30, 2023
@doawoo
Copy link
Contributor

doawoo commented Dec 2, 2023

I went and checked out your repo and managed to make it all function properly with no changes based on the main burrito branch:

image

I'll close this for now, but feel free to open it if you're still running into any issues!

@doawoo doawoo closed this as completed Dec 2, 2023
@zoedsoupe
Copy link
Author

I still do not realised to make work into my computer. Maybe there’s something missing?

issuing mix release generates correctly the burrito_out/exlings_macos_m1, however I keep receiving this strange behaviour:

 ./burrito_out/exlings_macos_m1

11:13:51.803 [notice] Application exlings exited: exited in: Exlings.start(:normal, [])
    ** (EXIT) an exception was raised:
        ** (UndefinedFunctionError) function Exlings.start/2 is undefined or private
            (exlings 0.1.0) Exlings.start(:normal, [])
            (kernel 9.1) application_master.erl:293: :application_master.start_it_old/4
Kernel pid terminated (application_controller) ("{application_start_failure,exlings,{bad_return,{{'Elixir.Exlings',start,[normal,[]]},{'EXIT',{undef,[{'Elixir.Exlings',start,[normal,[]],[]},{application_master,start_it_old,4,[{file,\"application_master.erl\"},{line,293}]}]}}}}}")

Crash dump is being written to: erl_crash.dump...done

I did some modifications on the project, adding some features, but the Exlings.Application module stills untouched.

I do have zig, xz and elixir executable, otherwise it shouldn’t build the project. But i really don’t udnerstand why i’m receiving this error.

I also tried to build a docker image with the CLI on ghcr.io/zoedsoupe/exlings:prod but no success:

> docker run ghcr.io/zoedsoupe/exlings:prod

rosetta error: failed to open elf at /lib64/ld-linux-x86-64.so.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants