Maxximiliann

Maxximiliann

(ArgumentError) argument error (stdlib) :ets.lookup_element(:hackney_config, :mod_metrics, 2)

(Please note: Elixir Experience Level: Beginner)


** (ArgumentError) argument error
    (stdlib) :ets.lookup_element(:hackney_config, :mod_metrics, 2)
    /home/maxximiliann/arbit/deps/hackney/src/hackney_metrics.erl:27: :hackney_metrics.get_engine/0
    /home/maxximiliann/arbit/deps/hackney/src/hackney_connect.erl:78: :hackney_connect.create_connection/5
    /home/maxximiliann/arbit/deps/hackney/src/hackney_connect.erl:47: :hackney_connect.connect/5
    /home/maxximiliann/arbit/deps/hackney/src/hackney.erl:333: :hackney.request/5
    lib/httpoison/base.ex:793: HTTPoison.Base.request/6
    lib/pump.ex:11: Pump.get_trading_activity/0

How do I resolve this error?

Thanks for all your help :slight_smile:

Marked As Solved

dom

dom

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.

Also Liked

axelson

axelson

Scenic Core Team

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.

dom

dom

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.

There’s some more discussion on that in the tutorial: https://elixir-lang.org/getting-started/mix-otp/supervisor-and-application.html#the-application-callback

maz

maz

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:

defmodule FaithfulWord.ReleaseTasks do
  @start_apps [
    :crypto,
    :ssl,
    :postgrex,
    :ecto,
    :ecto_sql,
    :httpoison, # add
    :poison # add
  ]

... 
  defp start_services do
    IO.puts("Starting dependencies..")
    # Start apps necessary for executing migrations
    Enum.each(@start_apps, &Application.ensure_all_started/1)

    # Start the Repo(s) for app
    IO.puts("Starting repos..")
    Enum.each(@repos, & &1.start_link(pool_size: 2))
  end

Where Next?

Popular in Questions Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
kostonstyle
Hi all I want to have a unix time, from the current time plus 1 hour. DateTime.now + 1 hour How to get it in elixir? Thanks
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
idi527
I’ve been re-reading swift book again and noticed that multiline strings there don’t have a trailing line break, unlike in elixir iex(2)...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3268 119930 1237
New
JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
New
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New

We're in Beta

About us Mission Statement