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:

https://github.com/benoitc/hackney/blob/1.15.2/src/hackney_app.erl#L21

https://github.com/benoitc/hackney/blob/1.15.2/src/hackney_sup.erl#L40

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

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New

Other popular topics Top

TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 41539 114
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 43622 214
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement