Create standalone executable that uses another executable

227 views
Skip to first unread message

Rod Schmidt

unread,
May 28, 2015, 8:04:29 PM5/28/15
to elixir-l...@googlegroups.com
I'm trying to create a standalone executable using mix escript.build. It seems to work, but when I run it. I get this:

** (EXIT from #PID<0.49.0>) an exception was raised:
    ** (ArgumentError) argument error
        :erlang.++({:error, :bad_name}, '/ale')
        lib/i2c.ex:59: I2c.init/1
        (stdlib) gen_server.erl:306: :gen_server.init_it/6
        (stdlib) proc_lib.erl:239: :proc_lib.init_p_do_apply/3

What its trying to do is run another executable called ale. This works fine when I do things from iex -S mix. The dependencies I'm using is called elxir_ale (http://github.com/fhunleth/elixir_ale). The executable (ale) is in the priv directory under the _build directory. I thought I read somewhere that mix is supposed to create a symlink to embedded executables like ale, but I don't see that being done. Here's my mix.ex:

defmodule ExGoPiGo.Mixfile do
  use Mix.Project

  def project do
    [app: :exgopigo,
     version: "0.0.1",
     name: "ExGoPiGo",
     elixir: "~> 1.0",
     # build_embedded: Mix.env == :prod,
     # start_permanent: Mix.env == :prod,
     escript: escript_config,
     deps: deps]
  end

  # Configuration for the OTP application
  #
  # Type `mix help compile.app` for more information
  def application do
    [applications: [:logger, :elixir_ale]]
  end

  # Dependencies can be Hex packages:
  #
  #   {:mydep, "~> 0.3.0"}
  #
  # Or git/path repositories:
  #
  #   {:mydep, git: "https://github.com/elixir-lang/mydep.git", tag: "0.1.0"}
  #
  # Type `mix help deps` for more examples and options
  defp deps do
    [
      { :elixir_ale,  "~> 0.3.0" },
      { :ex_doc,      github: "elixir-lang/ex_doc" }
    ]
  end

  defp escript_config do
    [main_module: ExGoPiGo]
  end

end


Any thoughts on what I'm missing?

Thanks,

Rod

José Valim

unread,
May 29, 2015, 3:15:38 AM5/29/15
to elixir-l...@googlegroups.com
escripts do not work when they need to read values from priv. I will update the docs to make it clear. Thanks for reporting.



José Valim
Skype: jv.ptec
Founder and Lead Developer

--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/5192a0fc-8df5-4f34-9cd9-0bfa49ef5267%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jason M Barnes

unread,
May 29, 2015, 8:29:52 AM5/29/15
to elixir-l...@googlegroups.com
NIFs tend to place shared object libraries in priv/ so maybe a note that escripts will only work for pure Elixir/Erlang code would be helpful.

Reply all
Reply to author
Forward
0 new messages