Fixing "FATAL:udev_loader.cc(38) Check failed: false." errors on NixOS
This is a problem that I ran into while figuring out how to get Pixelator
running–the issue is that electron apps expect to be linked against the old
libudev.so.0
, not the new libudev.so.1
.
The error itself looks like
Start init.
[1654:1009/144147.908343:FATAL:udev_loader.cc(38)] Check failed: false.
#0 0x00000378afa7 <unknown>
#1 0x0000037cb27b <unknown>
#2 0x000001109cd3 <unknown>
#3 0x000001109626 <unknown>
#4 0x000001109d50 <unknown>
#5 0x000003b68084 <unknown>
#6 0x0000037a2370 <unknown>
#7 0x00000376facd <unknown>
#8 0x00000376fde8 <unknown>
#9 0x000003770486 <unknown>
#10 0x000003725fd9 <unknown>
#11 0x00000376f7f7 <unknown>
#12 0x000003777dde <unknown>
#13 0x000000d3a5a5 <unknown>
#14 0x000000d3a753 <unknown>
#15 0x00000377bd47 <unknown>
#16 0x00000377a383 <unknown>
#17 0x7fc748e13ef7 start_thread
#18 0x7fc74720622f __GI___clone
fish: “./pixelator” terminated by signal SIGABRT (Abort)
Luckily, there is a stub package we can use as a work around–
* nixpkgs.libudev0-shim (libudev0-shim)
Shim to preserve libudev.so.0 compatibility
How to use libudev0-shim
The trick is to modify your built binary so that its LD_LIBRARY_PATH
includes
libudev0-shim
. This is done via makeWrapper
, which wraps the binary with the
customized path.
Here’s an example:
with import <nixpkgs> {};
let
autopatchelf = import ../default.nix;
in
stdenv.mkDerivation {
name = "pixelator";
src = ~/downloads/pixelator-1.0.5-linux-x64.zip;
nativeBuildInputs = [
libudev0-shim
udev
dpkg
autopatchelf
unzip
zlib
harfbuzz
freetype
makeWrapper
];
libs = stdenv.lib.makeLibraryPath [
glibc
libgcc
gcc-unwrapped
gtk2-x11
zlib
gnome2.pango
atk
cairo
gdk_pixbuf
glib
fontconfig
freetype
dbus_daemon.lib
dbus.lib
xlibs.libX11
xlibs.libxcb
xlibs.libXi
xlibs.libXcursor
xlibs.libXdamage
xlibs.libXrandr
xlibs.libXcomposite
xlibs.libXext
nix
xlibs.libXfixes
xlibs.libXrender
xlibs.libXtst
xlibs.libXScrnSaver
gnome2.GConf.out
nss.out
alsaLib.out
nspr.out
cups.lib
xorg_sys_opengl.out
expat.out
harfbuzz.out
libudev0-shim
];
installPhase = ''
chmod +xX pixelator
chmod +xX _pixelator_cmd.exe
mkdir -p $out/bin
mv * $out
autopatchelf $out
ln -s $out/pixelator $out/bin/pixelator
ln -s $out/_pixelator_cmd.exe $out/bin/_pixelator_cmd.exe
'';
preFixup = let
runtimeLibs = lib.makeLibraryPath [ libudev0-shim ];
in ''
wrapProgram "$out/pixelator" --prefix LD_LIBRARY_PATH : ${runtimeLibs}
'';
dontStrip = true;
}
The highlighted bits are what you need. Notice the wrapping is done during the
preFixup
phase build phase, so after the binary has been built etc.
Further Reading
For more examples of usage of libudev0-shim
, try this GitHub custom
search.