- Replace the NEEDED entry with patchelf After the Rust build (so target/maturin/libgraphbit.so exists) and before maturin’s copy/repair step, run:
From the graphbit repo root (or wherever target/maturin/libgraphbit.so is)patchelf --replace-needed '/home/infinitibit/Downloads/graphbit-feature-metadata-json-schema/guardrail_ffi/../vendor/guardrail/libguardrail_ffi.so' 'libguardrail_ffi.so' target/maturin/libgraphbit.so
If the NEEDED string is the relative form, use: patchelf --replace-needed 'guardrail_ffi/../vendor/guardrail/libguardrail_ffi.so' 'libguardrail_ffi.so' target/maturin/libgraphbit.so Check what’s actually in the binary: readelf -d target/maturin/libgraphbit.so | grep NEEDED Use the exact string you see there in --replace-needed. 2. Run maturin so it can find libguardrail_ffi.so Maturin will look for libguardrail_ffi.so by name. Put it somewhere it can see it, e.g.: Keep it in vendor/guardrail/libguardrail_ffi.so and add that directory to LD_LIBRARY_PATH when running maturin: export LD_LIBRARY_PATH="$(pwd)/vendor/guardrail:$LD_LIBRARY_PATH" maturin build --release or Copy libguardrail_ffi.so next to libgraphbit.so before building: cp vendor/guardrail/libguardrail_ffi.so target/maturin/ then run maturin build --release (after the patchelf step). 3. Automate in CI/local To avoid doing this by hand every time: patchelf: run the patchelf --replace-needed ... libguardrail_ffi.so target/maturin/libgraphbit.so in a build step after cargo build and before maturin build (e.g. in a script or in the GraphBit workflow for Linux). Rpath: so the installed wheel finds the .so next to the extension, add an rpath when linking or with patchelf, e.g. patchelf --set-rpath '$ORIGIN' target/maturin/libgraphbit.so and ship libguardrail_ffi.so in the same directory as libgraphbit.*.so in the wheel. Summary: replace the NEEDED path with libguardrail_ffi.so using patchelf, then run maturin with libguardrail_ffi.so available (e.g. via LD_LIBRARY_PATH or by copying it next to libgraphbit.so). That removes the bad destination path and fixes the "No such file or directory" copy error.