There should be error indicating issue ets encoutered. I have had my fair share of issues with ets and the community is great with noobs to help them out. you can check out my issue to know what stracktrace I am referring to and also might help you in debugging
Erlang/Elixir libraries are packaged as applications, with start and stop functions responsible for initializing or tearing down everything the app needs to run: supervision tree, registered processes, ETS tables, etc.
In this case the missing resource is an ETS table which Hackney creates when it starts:
Most likely you can fix it by ensuring Hackney is started. In mix.exs, how did you specify the dependency? Make sure it doesn’t have a flag like runtime: false or only: :test.
If you’re on an old Elixir, you may also have to add it under applications, which controls what applications (dependencies) get started before your app. More modern Elixir uses extra_applications instead and generally figure out dependencies automatically.
If you didn’t specify Hackney as a dependency at all - then perhaps it got brought in indirectly by HTTPoison. Then you need to make sure that HTTPoison is being started instead, which should automatically start Hackney.
It looks fine. Try iex -S mix (or iex -S mix run) rather than iex -S mix compile.
mix run loads and runs your application and its dependencies, whereas mix compile only compiles the application without starting it. You’ll see the difference if you call Application.started_applications() in your iex shell after starting it.
I encountered the same error when running integration changes on prod when initializing the meilisearch-elixir module. What was really odd was I wasn’t encountering this error stack on a separate project using the same module. So I’m assuming it was a race condition here:
faithful_word | ** (ArgumentError) errors were found at the given arguments:
faithful_word |
faithful_word | * 1st argument: the table identifier does not refer to an existing ETS table
faithful_word |
faithful_word | (stdlib 3.15.2) :ets.lookup_element(:hackney_config, :mod_metrics, 2)
faithful_word | /app/deps/hackney/src/hackney_metrics.erl:27: :hackney_metrics.get_engine/0
faithful_word | /app/deps/hackney/src/hackney_connect.erl:75: :hackney_connect.create_connection/5
faithful_word | /app/deps/hackney/src/hackney_connect.erl:44: :hackney_connect.connect/5
faithful_word | /app/deps/hackney/src/hackney.erl:335: :hackney.request/5
faithful_word | lib/httpoison/base.ex:846: HTTPoison.Base.request/6
faithful_word | lib/meilisearch/http.ex:40: Meilisearch.HTTP.delete_request/3
faithful_word | (stdlib 3.15.2) erl_eval.erl:685: :erl_eval.do_apply/6
The solution was quite similar, I had to ensure that :httpoison and :poison were started before launching:
That shouldn’t be necessary since Elixir can infer the required start order by default. Are you setting :applications in mix.exs? Or are you setting runtime: false on those deps?
No, using :extra_applications like what you are using is what I would recommend.
Ah, I see what’s happening. Normally I’d let Application.ensure_all_started(:faithful_word) start all of the dependencies of your application. But since you’re starting all the dependencies manually you have to add any transitive dependencies (i.e. dependencies of your dependencies) as well.