#Does anyone know why it works when I "gleam run" it, but has an exception with gleescript?

1 messages · Page 1 of 1 (latest)

hot drift
#

Code: https://github.com/devries/vulnlist/blob/main/src/vulnlist.gleam
OS: macOS 14.4.1 (m3)
Gleam version: 1.1.0
BEAM stack: rebar 3.23.0 on Erlang/OTP 26 Erts 14.2.5

Exception is below:

escript: exception error: bad argument
  in function  ets:lookup_element/3
     called as ets:lookup_element(hackney_config,mod_metrics,2)
     *** argument 1: the table identifier does not refer to an existing ETS table
  in call from hackney_metrics:get_engine/0 (/Users/devries/Projects/learning/vulnlist/build/dev/erlang/hackney/src/hackney_metrics.erl, line 27)
  in call from hackney_connect:create_connection/5 (/Users/devries/Projects/learning/vulnlist/build/dev/erlang/hackney/src/hackney_connect.erl, line 75)
  in call from hackney_connect:connect/5 (/Users/devries/Projects/learning/vulnlist/build/dev/erlang/hackney/src/hackney_connect.erl, line 44)
  in call from hackney:request/5 (/Users/devries/Projects/learning/vulnlist/build/dev/erlang/hackney/src/hackney.erl, line 335)
  in call from gleam_hackney_ffi:send/4 (/Users/devries/Projects/learning/vulnlist/build/dev/erlang/gleam_hackney/_gleam_artefacts/gleam_hackney_ffi.erl, line 7)
  in call from gleam@hackney:send_bits/1 (/Users/devries/Projects/learning/vulnlist/build/dev/erlang/gleam_hackney/_gleam_artefacts/[email protected], line 23)
  in call from gleam@hackney:send/1 (/Users/devries/Projects/learning/vulnlist/build/dev/erlang/gleam_hackney/_gleam_artefacts/[email protected], line 50)

It looks like something to do with hackney, but is there a workaround?

GitHub

Contribute to devries/vulnlist development by creating an account on GitHub.

timid isle
#

How strange

heavy ridge
#

Maybe the hackney app wasn't started

timid isle
#

It should be

#

Does it persist if you gleam clean and then try again?

hot drift
#

I tried doing a gleam clean and then gleam run -m gleescript again, but I still get the same exception.

timid isle
#

Wait

#

I missed the gleescript bit

#

What exactly are you running to get an error?

hot drift
#

I do the following sequence:

gleam run -m gleescript
chmod u+x ./vulnlist
./vulnlist
timid isle
#

Ah I see

hot drift
#

However, if I just do gleam run then it runs fine.

timid isle
#

I don't remember what gleescript does but it might not be starting the dependency OTP applications for you like gleam run does

hot drift
#

Ok. I can write a shell script that changes into the directory and executes gleam run so it's no big deal.

timid isle
#

Try adding a call to application:ensure_all_started(vulnlist). at the start of your program

#

And if you could open an issue with gleescript that'd be cool

hot drift
#

ok, will do

timid isle
hot drift
#

I haven't done any erlang and it's not clear to me where I would put that call. I see that ensure_all_started is in the gleam/erlang library, but I am not sure what to use as the argument.

timid isle
#

You'd put the name of your application as an atom