RPATH of binary contains a forbidden reference to /build/

You can patch RPATH with patchelf. But ideally, you would figure out why that is happening and correct the project’s build system.

Generally, if a project adds build directories to rpath entries, it is expected to patch them out during installation. If it does not, it should probably be considered a bug in the upstream build script.

For debugging, you could use

nativeBuildInputs = [
  …
  patchelf
];

postInstall = ''
  patchelf --print-rpath "$out/lib/julia/libgmpxx.so.4.6.0"
'';

to find out what is actually in the DT_RUNPATH entry and then grep the project source code for rpath.

In CMake-based projects, you can also sometimes work around this by adding -DCMAKE_SKIP_BUILD_RPATH=ON to cmakeFlags, or ensuring CMAKE_SKIP_INSTALL_RPATH is not on. But the issue still indicates something is wonky with the project’s CMake definitions so a proper solution is is still preferred.

1 Like