diff --git a/CHANGELOG.md b/CHANGELOG.md index 026907d8769..c4c1b3eaae3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -227,6 +227,10 @@ the left-hand side was a function call. ([Surya Rose](https://github.com/GearsDatapacks)) + - Fixed a bug where Gleam would be unable to compile to BEAM bytecode on older + versions of Erlang/OTP. + ([yoshi](https://github.com/joshi-monster)) + ## v1.6.1 - 2024-11-19 ### Bug fixed diff --git a/compiler-cli/templates/gleam@@compile.erl b/compiler-cli/templates/gleam@@compile.erl index 3e0a645b737..4622976100f 100644 --- a/compiler-cli/templates/gleam@@compile.erl +++ b/compiler-cli/templates/gleam@@compile.erl @@ -147,10 +147,18 @@ do_compile_elixir(Modules, Out) -> end. add_lib_to_erlang_path(Lib) -> - code:add_paths(filelib:wildcard([Lib, "/*/ebin"])). + code:add_paths(expand_lib_paths(Lib)). +-if(?OTP_RELEASE >= 26). del_lib_from_erlang_path(Lib) -> - code:del_paths(filelib:wildcard([Lib, "/*/ebin"])). + code:del_paths(expand_lib_paths(Lib)). +-else. +del_lib_from_erlang_path(Lib) -> + lists:foreach(fun code:del_path/1, expand_lib_paths(Lib)). +-endif. + +expand_lib_paths(Lib) -> + filelib:wildcard([Lib, "/*/ebin"]). configure_logging() -> Enabled = os:getenv("GLEAM_LOG") /= false,