gleam-lang / otp

📫 Fault tolerant multicore programs with actors
https://hexdocs.pm/gleam_otp/
Apache License 2.0
443 stars 49 forks source link

fix: system message returned from GetState #56

Closed kodumbeats closed 8 months ago

kodumbeats commented 8 months ago

Between Erlang/OTP 26.0 and 26.1, the interface for system messages changed from a literal type to result type, breaking our implementation. See OTP-18633 for more information.

This patch updates the library to 26.1, but sets a minimum version requirement. Since this is such a niche API (debugging only), we agreed that documentation is sufficient to enforce versions.

Open Questions

Tests pass locally, though some files need a reformat. Will address separately.

# Erlang/OTP 26.1

kdmb@nas ~/g/k/gleam_otp (fix/erlang_system_message_interface)> asdf current erlang
erlang          26.1.2          /home/kdmb/.tool-versions
kdmb@nas ~/g/k/gleam_otp (fix/erlang_system_message_interface)> gleam test
  Compiling gleam_otp
   Compiled in 0.34s
    Running gleam_otp_test.main
...............
Finished in 0.281 seconds
15 tests, 0 failures

# Erlang/OTP 26.2

kdmb@nas ~/g/k/gleam_otp (fix/erlang_system_message_interface)> asdf current erlang
erlang          26.2.1          /home/kdmb/.tool-versions
kdmb@nas ~/g/k/gleam_otp (fix/erlang_system_message_interface)> gleam test
   Compiled in 0.01s
    Running gleam_otp_test.main
...............
Finished in 0.282 seconds
15 tests, 0 failures
tankorsmash commented 7 months ago

I'll mention this for posterity in case it helps anyone running into the same issue until this is live:

You can use kerl to install different versions of erlang, so for now, you need to do something like

# install older version of erlang
kerl build 26.0.1
kerl install 26.0.1 ~/erlang/v26.0.1 # or whichever path you prefer

# activate the installation
. ~/erlang/v26.0.1/activate

# to check the version
erl -eval '{ok, Version} = file:read_file(filename:join([code:root_dir(), "releases", erlang:system_info(otp_release), "OTP_VERSION"])), io:fwrite(Version), halt().' -noshell
>> 26.0.1

# once you're done editing, or want to install a new one
kerl_deactivate

I can confirm 26.2.2 is broken with gleam_otp v0.9.0, and that activating 26.0.1 allows for calling system.get_state without failing.

Not sure what other implications going to a different version of erlang might have though.

lpil commented 7 months ago

Sorry, I should have released this. I'll do that now.