Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing priv library does not trigger re-compile #616

Closed
ggwpez opened this issue Jun 1, 2024 · 1 comment · Fixed by #624
Closed

Missing priv library does not trigger re-compile #616

ggwpez opened this issue Jun 1, 2024 · 1 comment · Fixed by #624

Comments

@ggwpez
Copy link

ggwpez commented Jun 1, 2024

Hey thanks for the project, really useful 😄

When I delete the .so files in the priv/native/ folder, then the following mix test invocation will error that they are not found:

error: module ErasureCoding.Native is not loaded and could not be found
    │
  3 │   doctest ErasureCoding.Native
    │   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    │
    └─ test/bindings/erasure_coding_test.exs:3: Bindings.ErasureCoding.Test (module)


20:57:18.167 [warning] The on_load function for module Elixir.ErasureCoding.Native returned:
{:error,
 {:load_failed,
  ~c"Failed to load NIF library: 'dlopen(... 'graymatter/priv/native/liberasure_coding.so' (no such file)'"}}

I got around this by adding:

@external_resource "priv/native/liberasure_coding.so"

To my NIF module here. Is this expected or could maybe Rustler already generate this attribute in its derive macro?

Having it auto recompile in these cases helps when Ctrl-C-ing the build or in CI where caching does not restore everything.
Hopefully this is easy to reproduce, otherwise I will make an example project.

{:rustler, "~> 0.33.0"},
$ elixir -v
Erlang/OTP 26 [erts-14.2.5] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]
Elixir 1.16.3 (compiled with Erlang/OTP 26)

on MacOS 14.5
@filmor
Copy link
Member

filmor commented Jun 20, 2024

The issue is simply that we currently don't count the copied build artifacts themselves as "external resources". It's not hard to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants