Sean Mackesey
Sean Mackesey

Reputation: 10939

Access IEx.pry from escript

I am new to Elixir and have been debugging my code by starting with iex -S mix and putting IEx.pry breakpoints in functions. I've now packaged some code as a command-line app (using escript) and am trying to invoke IEx.pry after running my code via the escript executable. However, the function is not available -- IEx is apparently not bundled with the executable. How can I access IEx.pry from my executable?

Upvotes: 1

Views: 90

Answers (1)

Aleksei Matiushkin
Aleksei Matiushkin

Reputation: 120990

While you are strongly discouraged to do that (escript is considered to be a release/production entity, you are supposed to debug it till it works and release afterwards,) it’s still possible: just list iex in the list of applications within your project’s mix.exs:

def project do
  [
    app: @application,
    version: @version,
    ...,
    deps: [
      {:iex, "~> 1.6"},
      ...
    ]
  ]
end

And start it as a dependent application, since it’s likely needed to be started:

def application do
  [
    mod: {MyApp.Application, []},
    extra_applications: ~w|iex|a
  ]
end

Upvotes: 2

Related Questions