Closed ori-nonni closed 2 hours ago
I used code:del_paths
in the Erlang compiler backend because the standard library only supports the latest 2 versions. This function was introduced in Erlang/OTP 26, which is the oldest version the standard library currently supports. This has come up for a lot of folks now, and I kind of like that it fails loud and early instead of at some random point at runtime whenever a non-supported function is called. Of course the error you get is super bad at the moment.
Technically, you could run Gleam without the standard library or with a really old version, so now I'm not sure if having the same requirement in the compiler is a good idea.
Maybe adding a erlang.min_version
field to gleam.toml
for the standard library and other libraries that want to do ffi (like gleam_json@2
) would be good? We could then start checking that one the same way we check the minimum Gleam version. This would give us a way to have nice errors during compile time. Of course I could also remove the call to del_paths
again.
~ :purple_heart:
I'm a total noob, but adding the erlang version as a dependency for the standard library seems like a good solution. I assume that would generate a nice error message?
Yeah! it could roughly look like this:
$ gleam build
Compiling gleam_stdlib
error: Incompatible Erlang version
The package `gleam_stdlib` requires an Erlang/OTP version satisfying >= 26 but you are using v25.3.2.15.
We will not support version checking in the build tool at all. That's a runtime property so it cannot be checked by the build tool, but it can be checked by your program.
Let's make the Erlang compiler emit a helpful error in the instance this function is unavailable.
Wouldn't it b better to not use that function in the first place?
We will not support version checking in the build tool at all. That's a runtime property so it cannot be checked by the build tool, but it can be checked by your program.
Let's make the Erlang compiler emit a helpful error in the instance this function is unavailable.
In the general case (i.e. not just related to code:del_paths) how does the compiler know that an issue is due to the wrong Erlang version to point the user in the right direction?
If we can replace that call with one that works on older versions that would be good too.
@ori-nonni The compiler does not know that. It doesn't know much of anything about runtime.
We will not support version checking in the build tool at all. That's a runtime property so it cannot be checked by the build tool, but it can be checked by your program.
@ori-nonni The compiler does not know that. It doesn't know much of anything about runtime.
I would assume that the build environment is known by the build tool when building, including what version erlang is available. (parsing erl -version
in the worst case).
So wouldn't it make sense to be able to specify a minimum erlang version in the toml as a dev dependency since it is known at build time?
When I run gleam build
without erlang installed I get a nice error message. Is the lack of escript less of a runtime property than the available erlang version when building?
error: Program not found
The program `escript` was not found. Is it installed?
Documentation for installing Erlang can be viewed here:
https://gleam.run/getting-started/installing/
It's not known, no. We will not be attempt to support this. There is no way for the build tool to know what VM version is going to be used on your production computers.
Gleam version 1.6.2 WSL running Ubuntu 24.04.1
I installed Gleam using nix home manager and then installed erlang in the same way.
I got an error when I ran
gleam build
The issue was that home manager installs Erlang 25 by default, but it seems that Erlang 27 is required for Gleam.
Would it be possible to inform the user that they need to install the correct version of Erlang instead of erroring with a fairly cryptic error?