lustre-labs / dev-tools

Lustre's CLI and development tooling: zero-config dev server, bundling, and scaffolding.
55 stars 18 forks source link

ESBuild Platform Detection Issue - Windows #14

Closed Svaught598 closed 8 months ago

Svaught598 commented 8 months ago

Hello! I'm running into an issue during the Detecting Platform step of the ESBuild install. I get this error after running gleam run -m lustre/dev start --use-example-styles.

exception error: construction of binary failed
  in function  lustre_dev_tools@esbuild:explain/1 (c:/Users/Svaug/projects/gleam/example/build/dev/erlang/lustre_dev_tools/_gleam_artefacts/lustre_dev_tools@esbuild.erl, line 177)
     *** segment 2 of type 'binary': expected a binary but got: {ok,<<"x64">>}

I'm not super familiar with Erlang, but my after some digging, I think it might be an issue with get_cpu in lustre_dev_tools_ffi.erl. It appears that a result is being returned for windows:

get_cpu() ->
    case erlang:system_info(os_type) of
        {unix, _} ->
            [Arch, _] = string:split(erlang:system_info(system_architecture), "-"),
            list_to_binary(Arch);
        {win32, _} ->
            case erlang:system_info(wordsize) of
                4 -> {ok, <<"ia32">>};
                8 -> {ok, <<"x64">>}
            end
    end.

while the gleam external declaration suggests it should return a bitstring:

@external(erlang, "lustre_dev_tools_ffi", "get_cpu")
fn get_cpu() -> String

If this seems like the right track, I would be more than happy to put up a PR to resolve this!

hayleigh-dot-dev commented 8 months ago

Oh no! What a good spot, a PR would be wonderful!