Running migration from release tzdata error

I was following the blog post by platformatec to be able to run migrations from my release. When I run the command
rel/my_app/bin/my_app command Elixir.MyApp.Release.Tasks migrate

I get the following error:
{"init terminating in do_boot",{function_clause,[{'Elixir.MyApp.Release.Tasks',check_started_response,[{error,{tzdata,{"no such file or directory","tzdata.app"}}}],[{file,"web/scripts/release_tasks.ex"},{line,17}]},{'Elixir.Enum','-map/2-lists^map/1-0-',2,[{file,"lib/enum.ex"},{line,1088}]},{'Elixir.Enum','-map/2-lists^map/1-0-',2,[{file,"lib/enum.ex"},{line,1088}]},{'Elixir.MyApp.Release.Tasks',migrate,0,[{file,"web/scripts/release_tasks.ex"},{line,9}]},{init,start_it,1,[]},{init,start_em,1,[]}]}}

The script is as follows:

defmodule MyApp.Release.Tasks do
  @app :my_app

  def migrate do
    Application.load(@app) |> check_started_response()
    results = Enum.map(Application.spec(@app, :applications), &Application.load(&1))
    Enum.map(results, &check_started_response/1)
    results = Enum.map(Application.spec(@app, :applications), &Application.ensure_all_started(&1))
    Enum.map(results, &check_started_response/1)

    path = Application.app_dir(:cymbal, "priv/master_repo/migrations")
    Ecto.Migrator.run(MyApp.MasterRepo, path, :up, all: true)

    :init.stop()
  end

  defp check_started_response(:ok), do: :ok
  defp check_started_response({:ok, _}), do: :ok
  defp check_started_response({:error, {:already_loaded, _}}), do: :ok

end

Using the exact (with changes for my specific app) code from the platformatec blog basically gave me the same error but the above code is from another forum post I ran into.

Any help would be incredible!

Had two versions of tzdata where in my mix.exs file I forced it into using the higher version. That ended up with there being two tzdata version in rel/my_app/lib.
One of those didn’t have an ebin directory and therefore was missing tzdata.app which was making the command fail. After resolving the dependency conflict it now works using the original release command posted by Platformatec

1 Like