firezone / wireguardex

Configure WireGuard® interfaces in Elixir using Rust NIFs.
https://hex.pm/packages/wireguardex
Apache License 2.0
71 stars 9 forks source link

Error downloading NIF during mix compile #37

Closed bengcooper closed 1 year ago

bengcooper commented 1 year ago

I'm encountering the following error whilst running mix compile with Wireguardex 0.3.6 as a dependency (with Elixir 1.15.7):

==> rustler_precompiled
Compiling 4 files (.ex)
Generated rustler_precompiled app
==> wireguardex
Compiling 8 files (.ex)

21:38:22.983 [debug] Downloading NIF from https://github.com/firezone/wireguardex/releases/download/v0.3.6/libwireguard_nif-v0.3.6-nif-2.16-x86_64-unknown-linux-gnu.so.tar.gz

== Compilation error in file lib/wireguardex.ex ==
** (RuntimeError) Error while downloading precompiled NIF: couldn't fetch NIF from https://github.com/firezone/wireguardex/releases/download/v0.3.6/libwireguard_nif-v0.3.6-nif-2.16-x86_64-unknown-linux-gnu.so.tar.gz: {:error, {:failed_connect, [{:to_address, {~c"github.com", 443}}, {:inet, [:inet], {:eoptions, {:undef, [{:tls_record, :supported_protocol_versions, [], []}, {:ssl, :default_versions, 1, [file: ~c"ssl.erl", line: 1715]}, {:ssl, :opt_versions, 3, [file: ~c"ssl.erl", line: 1704]}, {:ssl, :process_options, 3, [file: ~c"ssl.erl", line: 1629]}, {:ssl, :handle_options, 5, [file: ~c"ssl.erl", line: 1659]}, {:ssl, :connect, 4, [file: ~c"ssl.erl", line: 628]}, {:http_transport, :connect, 4, [file: ~c"http_transport.erl", line: 82]}, {:httpc_handler, :connect, 4, [file: ~c"httpc_handler.erl", line: 757]}]}}}]}}.

You can force the project to build from scratch with:

    config :rustler_precompiled, :force_build, wireguardex: true

In order to force the build, you also need to add Rustler as a dependency in your `mix.exs`:

    {:rustler, ">= 0.0.0", optional: true}

    lib/wireguardex.ex:13: (module)
could not compile dependency :wireguardex, "mix compile" failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile wireguardex --force", update it with "mix deps.update wireguardex" or clean it with "mix deps.clean wireguardex"

The URL is valid and I can download the NIF successfully.

Any idea what might be the cause?

jamilbk commented 1 year ago

Unable to reproduce over here. Perhaps a DNS or some other issue with your local mix?

bengcooper commented 1 year ago

I'll investigate further - it's occurring for me in both my local dev environment and inside a builder Docker image, but that doesn't exclude possible DNS issues.

It'll work fine copying the file from the local cache, just downloading from a fresh cache is the issue.

bengcooper commented 1 year ago

It appears this is an upstream issue to do with requiring the ssl application which was fixed in rustler_precompiled v0.6.1.

Bumping the version of rustler_precompiled dependency to the latest release (v0.7.0) seems to fix the issue.

jamilbk commented 1 year ago

Give this a whirl: https://hex.pm/packages/wireguardex/0.4.0

bengcooper commented 1 year ago

That's working great! Thanks so much for sorting it, I really appreciate all your work.