title: Elixir - How to include dependencies when making an escript application?
body: <p>I am trying to create a little CLI application in Elixir as a learning project. Parts of this program will require some datetime handling and as such I came upon the Elixir library [Calendar][calendar].</p>
  
  <p>It seems though that it does include the dependencies of [calendar] when I build it with this commands:</p>
  
  <pre><code>(mix clean &amp;&amp;)? mix escript.build 
  </code></pre>
  
  <p>as it throws me this error:</p>
  
  <pre><code>Could not start application tzdata: exited in: Tzdata.App.start(:normal, [])
  ** (EXIT) an exception was raised:
      ** (MatchError) no match of right hand side value: {:error, {:shutdown, {:failed_to_start_child, Tzdata.EtsHolder, {%ArgumentError{message: "unknown application: :tzdata"}, [{Application, :app_dir, 1, [file: 'lib/application.ex', line: 428]}, {Application, :app_dir, 2, [file: 'lib/application.ex', line: 437]}, {Tzdata.EtsHolder, :release_dir, 0, [file: 'lib/tzdata/ets_holder.ex', line: 86]}, {Tzdata.EtsHolder, :make_sure_a_release_dir_exists, 0, [file: 'lib/tzdata/ets_holder.ex', line: 70]}, {Tzdata.EtsHolder, :make_sure_a_release_is_on_file, 0, [file: 'lib/tzdata/ets_holder.ex', line: 64]}, {Tzdata.EtsHolder, :init, 1, [file: 'lib/tzdata/ets_holder.ex', line: 10]}, {:gen_server, :init_it, 6, [file: 'gen_server.erl', line: 328]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 247]}]}}}}
          (tzdata) lib/tzdata/tzdata_app.ex:15: Tzdata.App.start/2
          (kernel) application_master.erl:273: :application_master.start_it_old/4    
  </code></pre>
  
  <p>My <strong>mix.exs</strong> is as follows:</p>
  
  <pre><code>defmodule Cascli.Mixfile do
    use Mix.Project
  
    def project do
      [app: :cascli,
       version: "0.1.0",
       elixir: "~&gt; 1.4",
       build_embedded: Mix.env == :prod,
       start_permanent: Mix.env == :prod,
       escript: escript(),
       deps: deps()]
    end
  
    def escript do
      [ main_module: Cascli ]
    end
  
    def application do
      [ extra_applications: [ :logger, :calendar, :tzdata ] ]
    end
  
    defp deps do
      [
        { :poison,
          "~&gt; 3.0" },
        { :calendar,
          "~&gt; 0.16.1" },
        { :tzdata,      # Tried with and without this dependency
          "~&gt; 0.5.12" } # with no luck.
      ]
    end
  end
  </code></pre>
  
  <p>I have Googled and found an [issue][issue-5538] that was solved by [this pull request][pull-5540], but it does not seem to actually solve this particular case. It did however relate to escript building not taking into account dependencies of dependencies. I just don't know whether this is an Elixir issue or an issue with my setup/dependencies. The error is the same even if I try with or without the <strong>:tzdata</strong> entry in the deps and <strong>extra_applications</strong> fields.</p>
  
  <p>It still evades me though as to why it can't find tzdata at all, no matter if I have it as a dependency myself or not.</p>
  
  <pre><code>[calendar]:https://github.com/lau/calendar
  [pull-5540]:https://github.com/elixir-lang/elixir/pull/5540
  [issue-5538]:https://github.com/elixir-lang/elixir/issues/5538
  </code></pre>