Coder Social home page Coder Social logo

Comments (11)

bitwalker avatar bitwalker commented on July 22, 2024 5

You need to execute Application.ensure_all_started(:timex) in your migrations, the problem is that the :tzdata application is not running, and so that ETS table is missing. This doesn't happen when you run iex -S mix because Mix is starting :tzdata

from tzdata.

nathany avatar nathany commented on July 22, 2024 1

Thanks @lau. I made the same mistake too.

from tzdata.

lau avatar lau commented on July 22, 2024

Hi @bitwalker Did you put :tzdata in the applications list?

from tzdata.

bitwalker avatar bitwalker commented on July 22, 2024

Ah I still had it just in :included_applications. Sorry about that!

from tzdata.

lau avatar lau commented on July 22, 2024

No worries. Also keep in mind that users of Timex will have to have their app start Tzdata if it is ~> 0.5.1. For instance
by adding :tzdata to the applications: list in their mix.exs file. This is not required for ~> 0.1.7, but it won't hurt to add it.

That's why I added this to the Calendar readme. Maybe you want to add that (or something similar) too:

Also add tzdata to the list of applications in the mix.exs file:

  def application do
    [applications: [:logger, :tzdata]]
  end

from tzdata.

thisismydesign avatar thisismydesign commented on July 22, 2024

Hey,

I'm getting the same error when trying to use Tzdata 0.5.12 (e.g. Tzdata.canonical_zone_list) in a module attribute. It is present in the applications list. Taken from the getting started guide:

Any functions may be called when defining a module attribute.

Any idea what the issue might be?

from tzdata.

lau avatar lau commented on July 22, 2024

Hi @thisismydesign
Please update to the newest version of Tzdata (currently 0.5.16).
Which version of Elixir are you using? Tzdata needs to be started somehow. In certain versions of Elixir Tzdata (or a library using it, such as Calendar), needs to be in the applications list.

from tzdata.

thisismydesign avatar thisismydesign commented on July 22, 2024

@lau thanks for the quick reply!

0.5.16 behaves the same way. I'm using Tzdata natively and it's already in the applications list.

Elixir version:

Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Elixir 1.4.5

from tzdata.

thisismydesign avatar thisismydesign commented on July 22, 2024

My usage is like this:

defmodule Module do
  @timezones Tzdata.canonical_zone_list

from tzdata.

alfondotnet avatar alfondotnet commented on July 22, 2024

I am also getting the same, with a different call.

I have this piece of code:

    case Timex.Timezone.get(data) do
      {:error, _} = error ->
        error

      data ->
        {:ok, data}
    end

to put timezones that are saved in the database into a struct.

Well when running a migration that gets some data through an Ecto Query I get this error:

** (ArgumentError) argument error
    (stdlib) :ets.lookup(:tzdata_current_release, :release_version)
    lib/tzdata/release_reader.ex:47: Tzdata.ReleaseReader.current_release_from_table/0
    lib/tzdata/release_reader.ex:14: Tzdata.ReleaseReader.simple_lookup/1
    lib/tzdata/release_reader.ex:7: Tzdata.ReleaseReader.zone_and_link_list/0
    lib/tzdata.ex:40: Tzdata.zone_exists?/1
    lib/timezone/timezone.ex:152: Timex.Timezone.name_of/1
    lib/timezone/timezone.ex:180: Timex.Timezone.get/2
    lib/common/ecto/timezone.ex:27: Common.Ecto.Timezone.load/1
    (ecto) lib/ecto/type.ex:661: Ecto.Type.process_loaders/3
    (ecto) lib/ecto/schema.ex:1490: Ecto.Schema.load!/5
    (ecto) lib/ecto/schema.ex:1442: Ecto.Schema.safe_load_zip/4
    (ecto) lib/ecto/schema.ex:1443: Ecto.Schema.safe_load_zip/4
    (ecto) lib/ecto/schema.ex:1430: Ecto.Schema.__safe_load__/6
    (ecto) lib/ecto/repo/queryable.ex:282: Ecto.Repo.Queryable.process_source/6
    (ecto) lib/ecto/repo/queryable.ex:170: Ecto.Repo.Queryable.preprocess/5
    (postgrex) lib/postgrex/query.ex:77: DBConnection.Query.Postgrex.Query.decode_map/3
    (postgrex) lib/postgrex/query.ex:64: DBConnection.Query.Postgrex.Query.decode/3
    (db_connection) lib/db_connection.ex:1019: DBConnection.decode/6
    (ecto) lib/ecto/adapters/postgres/connection.ex:73: Ecto.Adapters.Postgres.Connection.prepare_execute/5
    (ecto) lib/ecto/adapters/sql.ex:256: Ecto.Adapters.SQL.sql_call/6

Which has that code in the stack trace and doing some Inspects can verify that that's indeed the call that triggers the error, although doing:

iex(1)> Timex.Timezone.get("America/Los_Angeles")
#<TimezoneInfo(America/Los_Angeles - PDT (-07:00:00))>

What's interesting is that if I run the same code iex -S mix works.

(Running 0.5.16 and

Erlang/OTP 20 [erts-9.2.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false]

Elixir 1.6.1 (compiled with OTP 20)

)

from tzdata.

alfondotnet avatar alfondotnet commented on July 22, 2024

Makes sense @bitwalker, thanks!

from tzdata.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.