[SOLVED] `libudev` replaced by `udev`?

Hi,

I was trying to install a cargo package: spl-token-cli (link), using cargo install spl-token-cli but I got the following error:

--- stderr
  thread 'main' panicked at 'Unable to find libudev: `"pkg-config" "--libs" "--cflags" "libudev"` did not exit successfully: exit status: 1
  error: could not find system library 'libudev' required by the 'hidapi' crate

  --- stderr
  Package libudev was not found in the pkg-config search path.
  Perhaps you should add the directory containing `libudev.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'libudev' found

Now I tried to add libudev to my configuration.nix or my flake.nix (in the buildInputs section) but they both gave me the error:

error: 'libudev' has been renamed to/replaced by 'udev'

So I replaced everything with udev but I still got the libudev not found error. How do I get rid of this error? Is it possible that I install some old version of libudev? Thanks!

1 Like

Because NixOS doesn’t work that way.

https://nixos.wiki/wiki/FAQ#I_installed_a_library_but_my_compiler_is_not_finding_it._Why.3F

The TL’DR is to not use cargo install, but to package with nix.

libudev was merged into systemd many years ago, nativeBuildInputs = [ pkg-config ]; buildInputs = [ systemd ]' should solve your issue.

7 Likes

@jonringer Beautiful. I did exactly this and installation succeeded. Thank you so much!

1 Like

Hi,
I think I have the same problem as rollschild, however I’m a noob a using cli. so I’m now too sure how to run the nativeBuildInputs and buildInputs command. currently running ubuntu cli on my window system.

I think you might be a bit confused here. This is a forum for the Nix package manager. If you’re not using it, buildInputs, nativeBuildInputs etc. don’t apply to you.

I’d recommend asking in forums for your specific distro. The solution on other distros should be to install the systemd package though.

oh right. my apologies and thanks for letting me know.

all packages are to be installed the nix way. agreed. but what to do if a package is not available in nix pkg manager. like the spl-token-cli

The solution becomes rather obvious when you do not treat nix a package manager, but a meta build tool…

You provide the build instructions for your dependency.

Or in Ubuntu/Arch/RedHat terms: You package that library.

1 Like