Hi! I was trying to get started with Gleam, and decided to start my journey with (what I thought) a rather simple task. My goal was to decode a string JSON from another service, and for that I stumble upon the gleam/json package. I installed brew install gleam and added gleam add gleam_json, and then executed my code:
let assert Ok(data) = json.decode(from: body, using: dynamic.field("name", dynamic.string))
But I kept getting the same error:
Insufficient Erlang/OTP version.
`gleam_json` uses the Erlang `json` module introduced in Erlang/OTP 27.
You are using Erlang/OTP 26
Please upgrade your Erlang install or downgrade to `gleam_json` v1.0.1.
I completely ignored the v1.0.1 suggestion, because I didn't understand what was Erlang/OTP. After a quick read on the Erlang/OTP documentation and confirming that brew install gleam installs the erlang@26:
➜ ~ brew info erlang
==> erlang: stable 26.2.5 (bottled), HEAD
I decided to do it the hard way. Then I installed brew install kerl alongside with Erlang/OTP 27 and uninstall gleam, and compile gleam from the make install repository. After a couple of hours and reading, I managed to have everything sorted, but even after installing the version OTP 27.0 version I was still getting the same error message...
Finally decided to install the gleam_json = "1.0.1" and ... it worked! but then I got curios and read the source code for the Erlang FFI and I noticed:
decode(Json) ->
thoas:decode(Json).
But I was expecting to use the newly JSON on the Erlang/OTP 27. After many other attempts, I changed the gleam_json dependency to >= 2.0.0 and to my surprise the error disappeared... I assume that this triggered something that updated something on gleam (cache, paths, ...)
It would really help to have a reference to kerl in gleam/json or asdf. And how to use a different Erlang version. I am still not sure if I did it correctly.