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

unable to run when from escript #24

Closed
binarytemple opened this issue Jul 31, 2016 · 6 comments
Closed

unable to run when from escript #24

binarytemple opened this issue Jul 31, 2016 · 6 comments

Comments

@binarytemple
Copy link

Hi, experimenting with various Elixir time libraries - https://github.com/binarytemple/poc_elixir_calendars/tree/escript_broken

Everything works fine in IEX session. But when escripted there is a crash at startup within the Tzdata application.

I build like so:

mix do deps.compile, escript.build && ./poc_elixir_calendars

The error (formatted) is the following:

{:error, {:shutdown,
    {:failed_to_start_child, Tzdata.EtsHolder,
     {%ArgumentError{message: "unknown application: :tzdata"},
    [
    {Application, :app_dir, 1, [file: 'lib/application.ex', line: 372]},
    {Application, :app_dir, 2, [file: 'lib/application.ex', line: 381]},
    {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: 240]
    }
    ]}}}}

The escript contains all the Tzdata files, including the ETS dump, '2016c.ets':

 % zipinfo poc_elixir_calendars | egrep -i '(ets|tz)'
-rw----     2.0 fat     1079 b- defN 31-Jul-16 21:14 tzdata.app
-rw----     2.0 fat    11516 b- defN 31-Jul-16 21:14 Elixir.Calendar.DateTime.TzPeriod.beam
-rw----     2.0 fat     5232 b- defN 31-Jul-16 21:14 Elixir.Tzdata.ReleaseUpdater.beam
-rw----     2.0 fat     9372 b- defN 31-Jul-16 21:14 Elixir.Tzdata.DataLoader.beam
-rw----     2.0 fat     3504 b- defN 31-Jul-16 21:14 Elixir.Tzdata.TableParser.beam
-rw----     2.0 fat  3397782 b- defN 31-Jul-16 21:14 2016c.ets
-rw----     2.0 fat     9932 b- defN 31-Jul-16 21:14 Elixir.Tzdata.Parser.beam
-rw----     2.0 fat    12232 b- defN 31-Jul-16 21:14 Elixir.Tzdata.beam
-rw----     2.0 fat     8292 b- defN 31-Jul-16 21:14 Elixir.Tzdata.DataBuilder.beam
-rw----     2.0 fat     5060 b- defN 31-Jul-16 21:14 Elixir.Tzdata.ReleaseReader.beam
-rw----     2.0 fat     3196 b- defN 31-Jul-16 21:14 Elixir.Tzdata.BasicDataMap.beam
-rw----     2.0 fat     6116 b- defN 31-Jul-16 21:14 Elixir.Tzdata.ParserOrganizer.beam
-rw----     2.0 fat     7640 b- defN 31-Jul-16 21:14 Elixir.Tzdata.EtsHolder.beam
-rw----     2.0 fat    19732 b- defN 31-Jul-16 21:14 Elixir.Tzdata.Util.beam
-rw----     2.0 fat     9368 b- defN 31-Jul-16 21:14 Elixir.Tzdata.FarFutureDynamicPeriods.beam
-rw----     2.0 fat     5204 b- defN 31-Jul-16 21:14 Elixir.Tzdata.LeapSecParser.beam
-rw----     2.0 fat     2236 b- defN 31-Jul-16 21:14 Elixir.Tzdata.App.beam
-rw----     2.0 fat     1088 b- defN 31-Jul-16 21:14 Elixir.Tzdata.TableData.beam
-rw----     2.0 fat    12828 b- defN 31-Jul-16 21:14 Elixir.Tzdata.PeriodBuilder.beam

Any suggestions?

@lau
Copy link
Owner

lau commented Jul 31, 2016

Hi Bryan

Tzdata versions 0.5 and higher don't work with escripts currently. Because escript don't work with ETS tables. AFAIK in future Elixir versions they will.
Try specifying tzdata version ~> 0.1.7 in your deps file. That should work.

-- Lau

@binarytemple
Copy link
Author

Thanks Lau. Changed version as suggested. Worked.

@kenbod
Copy link

kenbod commented Sep 16, 2016

Thanks for this discussion. It helped me workaround the same issue. I'm now motivated to learn how I can launch my application without using escript so I can avoid having to use an old version of tzdata in my project.

@binarytemple
Copy link
Author

@kenbod - some more discussion around the loading data when disconnected from the internet can be found here - #25 - perhaps it is possible to stay with escript but specify a data file load path outside the escript.

@kenbod
Copy link

kenbod commented Sep 16, 2016

Thanks, I'll check the "data file load path" option out if I find I need a newer version of tzdata.

@carlogilmar
Copy link

I try to use tzdata as transitive dependency from Calendar with escript and failed again... I had to downgrade

alexbrahastoll added a commit to alexbrahastoll/tt that referenced this issue Jun 13, 2019
As explained in lau/tzdata#24 (comment), more recent versions of tzdata are not compatible with releases (nor with escripts).
randycoulman added a commit to randycoulman/invoice_tracker that referenced this issue Nov 2, 2019
Up until now, I've been holding off on this upgrade because newer versions were trying to download an updated timezone database, which didn't work in an escript (see lau/tzdata#24).

But now, it is possible to turn off auto-updates and configure a different data directory, which solves the issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants