rustler: Running `mix test` does not work on the first run (needs to compile twice)

[Modify the `mix.exs` file]

$ mix test
Compiling NIF crate :rustler_test (native/rustler_test)...
    Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
Compiling 221 files (.ex)

13:15:37.820 [warn]  The on_load function for module Elixir.RustlerTest returned:
{:error, {:upgrade, 'Upgrade not supported by this NIF library.'}}

[Tests fail]

[Then, running again works]

$ mix test

[Tests succeed]

To make it work in travis CI I had to compile before running the tests:

 - MIX_ENV=test mix compile
 - mix test || travis_terminate 1

Same issue happens when trying to open the console with: iex -S mix

Rustler compiler is in the recommended order: compilers: [:rustler, :phoenix, :gettext] ++ Mix.compilers,

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 16 (13 by maintainers)

Commits related to this issue

Most upvoted comments

@rafapaez yes, @hansihe and I have noticed this happening. The issue is that the priv directory needs to exist before mix compile will properly symlink it to the _build directory. The way I’ve gotten around this is by committing a priv/.keep so that the priv dir always exists.

@scohen unfortunately, I don’t have access to hex/cargo for releases.

@hansihe can we get a new release?