adoptoposs / mjml_nif

Elixir NIF bindings for the MJML Rust implementation (mrml)
https://hexdocs.pm/mjml
MIT License
122 stars 17 forks source link

Issues with Docker and prebuild archives #67

Closed tmthn closed 2 years ago

tmthn commented 2 years ago

Using the prebuild mjml nif archive on GitLab CI within a CI job, an error raises while running the mix compile command.

Compiling 1 file (.ex)
14:45:01.534 [debug] Downloading NIF from https://github.com/adoptoposs/mjml_nif/releases/download/v1.3.5/libmjml_nif-v1.3.5-nif-2.16-x86_64-unknown-linux-musl.so.tar.gz
14:45:01.536 [debug] Using HTTP_PROXY: 
== Compilation error in file lib/mjml.ex ==
** (FunctionClauseError) no function clause matching in String.to_charlist/1    

    The following arguments were given to String.to_charlist/1:

        # 1
        nil

    Attempted function clauses (showing 1 out of 1):

        def to_charlist(+string+) when -is_binary(string)-

    (elixir 1.13.4) lib/string.ex:2401: String.to_charlist/1
    (rustler_precompiled 0.5.1) lib/rustler_precompiled.ex:611: RustlerPrecompiled.download_nif_artifact/1
    (rustler_precompiled 0.5.1) lib/rustler_precompiled.ex:468: RustlerPrecompiled.download_or_reuse_nif_file/1
    (rustler_precompiled 0.5.1) lib/rustler_precompiled.ex:124: RustlerPrecompiled.__using__/2
    lib/mjml.ex:22: (module)
could not compile dependency :mjml, "mix compile" failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile mjml", update it with "mix deps.update mjml" or clean it with "mix deps.clean mjml"

I am using the bitwalker/alpine-elixir:1.13 image.

paulgoetze commented 2 years ago

Hey @tmthn, thanks for reporting.

Hm, interesting, I figure this suggests that the determined host from the HTTP_PROXY system env var that you might have set is nil: https://github.com/philss/rustler_precompiled/blob/2e34accc510853b520a0e3953ff9722578fcb44e/lib/rustler_precompiled.ex#L611.

I think this might be the case if you have only a path instead of a full URI or an empty string for this env var? For me it looks like if the HTTP_PROXY/http_proxy env var is nil or a proper URI, then it should work.

tmthn commented 2 years ago

Ahhh i see, that did the trick. We used a proxy a while ago, someone left the env vars in there (probably me). Thanks for your help!