Recently, I came across this wonderful blog post on Parsing PDFs (and more) in Elixir using Rust. However, when trying out Github Actions CI with Rustler, I can’t seem to figure out the right steps to get mix compile to work.
Warning: 04:44:23.229 [warning] The on_load function for module Elixir.RustReader returned:
{:error,
{:load_failed,
~c"Failed to load NIF library /home/runner/work/elixir_pdf_tutorial/elixir_pdf_tutorial/_build/test/lib/elixir_pdf/priv/native/librustreader: 'libtika_native.so: cannot open shared object file: No such file or directory'"}}
How are people setting up their CI environments with Rustler and Phoenix projects?
We have a deps section in our CI yaml that looks something like what’s below. It looks like you are missing the rust tool chain, cargo deps fetch and rust compilation steps.
I think your setup would work with a simpler rust library because looking at your CI output you can see that rust dependencies are downloaded and rust is also compiling stuff.
Great point. This might be specific to this rust package. I can’t figure this out either in CI. I can run it on my Mac but I haven’t discerned why that is.
But I just build a simple rust CLI with extractous usage like in the article which works without complaining about libtika_native.so like with rustler.
So there might be some steps needed when used with rustler I can’t figure our right now.
Yes I think you are right about rustler. Building it in Github Action is trying to reference that libtika_native.so from that /runner/ folder. At this point, I am at a loss.
[warning] The on_load function for module Elixir.NifExtractous.Native returned:
{:error,
{:load_failed,
~c"Failed to load NIF library: 'dlopen(/Users/snewcomer/github/my_site/_build/dev/lib/nif_extractous/priv/native/libnif_extractous-v0.3.2-nif-2.17-aarch64-apple-darwin.so, 0x0002): Library not loaded: /Users/runner/work/nif-extractous/nif-extractous/target/aarch64-apple-darwin/release/build/extractous-1392444ace32bce9/out/tika-native/build/native/nativeCompile/libtika_native.dylib\n Referenced from: <D02FBE3D-DA3C-3332-9BD2-76946358E9A3> /Users/snewcomer/github/my_site/_build/dev/lib/nif_extractous/priv/native/libnif_extractous-v0.3.2-nif-2.17-aarch64-apple-darwin.so\n Reason: tried: '/Users/runner/work/nif-extractous/nif-extractous/target/aarch64-apple-darwin/release/build/extractous-1392444ace32bce9/out/tika-native/build/native/nativeCompile/libtika_native.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/runner/work/nif-extractous/nif-extractous/target/aarch64-apple-darwin/release/build/extractous-1392444ace32bce9/out/tika-native/build/native/nativeCompile/libtika_native.dylib' (no such file), '/Users/runner/work/nif-extractous/nif-extractous/target/aarch64-apple-darwin/release/build/extractous-1392444ace32bce9/out/tika-native/build/native/nativeCompile/libtika_native.dylib' (no such file)'"}
Rustler is not aware of the additional libraries that are copied in extractous’s build.rs. You will have to extend your build process to copy them from Rust’s target directory to priv/native/....