Maxximiliann

Maxximiliann

Compilation error in file - (ArgumentError) argument error (stdlib) :ets.lookup_element(:hackney_config, :mod_metrics, 2)

(Please note: Elixir Experience Level: Beginner)

iex -S mix
Erlang/OTP 21 [erts-10.2.4] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]

Compiling 2 files (.ex)

== Compilation error in file lib/pump.ex ==
** (ArgumentError) argument error
    (stdlib) :ets.lookup_element(:hackney_config, :mod_metrics, 2)
    /deps/hackney/src/hackney_metrics.erl:27: :hackney_metrics.get_engine/0
    /deps/hackney/src/hackney_connect.erl:78: :hackney_connect.create_connection/5
    /deps/hackney/src/hackney_connect.erl:47: :hackney_connect.connect/5
    /deps/hackney/src/hackney.erl:333: :hackney.request/5
    lib/httpoison/base.ex:793: HTTPoison.Base.request/6
    lib/httpoison.ex:128: HTTPoison.request!/5
    lib/pump.ex:4: (module)

What’s causing this error and what’s the solution?

Marked As Solved

NobbZ

NobbZ

By using defmodule you are creating a module, its body will get evaluated at compile time to eventually become the modules functions and then gets stored to disk.

Those module and the functions within can then be used at runtime to produce values.

Elixirs compilation though can also call function in another module and use the result to produce code that creates functions, so thats what your current code looks like it’s eventually trying to do that.

I’m not sure though if you really get what I’m writing, as I’m not sure how to explain properly, also I’m on the bus crowded with people and I can’t properly think in such an environment…

Also Liked

hubertlepicki

hubertlepicki

What’s in the pump.ex around line 4 where the error is? :slight_smile:

Maxximiliann

Maxximiliann

Thanks for your patient and detailed explanation. I used it to rework the code as follows:


def get_trading_activity do

 		case HTTPoison.get("https://api.wavesplatform.com/v0/pairs") do
			{:ok, _} ->
			results = HTTPoison.get!("https://api.wavesplatform.com/v0/pairs")

			json_into_atoms = Poison.decode!(results.body, keys: :atoms)
			

		#Exclude all pairs with volumeWAVES < 500

			Enum.filter(json_into_atoms.data, fn pairs -> pairs.data.volumeWaves >= 500.0 end)
    			
	
			{:error, %HTTPoison.Error{reason: reason}} ->
 			
			IO.inspect reason

		end
end

Thanks again!

NobbZ

NobbZ

Is there any reason you do that request at compile time?

If you really want to do that, you need to Application.ensure_started/1 for applications you need runtime features off.

Also most of the apps you specified in :extra_applications don’t belong there as they have been inferred by mix anyway because they are in deps.

hubertlepicki

hubertlepicki

Ah shoot I totally missed that. Yeah, that’s the reason, the applications like HTTpoison are not started at compile time. The whole code probably should be within some function.

Where Next?

Popular in Questions Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
logicmason
Hi there, I'm working through my first release with elixir/phoenix. I've built a release with distillery and found that it crashes when I...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
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
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
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
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

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
sergio
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
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
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
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
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

We're in Beta

About us Mission Statement