How to find package with `libcom_err.so.2`?

I’m trying to package something and autoPatchelfHook is complaining:

autoPatchelfHook could not satisfy dependency libcom_err.so.2 wanted by /nix/store/rsrgkb6rkm52fsg6dxb5cdms2l7rrs4b-nsight_systems-2021.5.2.53/nsight-systems/2021.5.2/target-linux-x64/CollectX/RedHat/x86_64/libssl.so.10

But despite my googling, I haven’t been able to track down which package contains this library. How do I located such a file?

It appears that searching for files in search.nixos.org does not work.

Ended up finding this in e2fsprogs of all places. Still, I’m confused about how to do this in general? Is there no better solution than rough googling and guess-and-check?

The most common approach is probably to use nix-index/nix-locate:

$ nix shell nixpkgs#nix-index -c nix-locate lib/libcom_err.so.2 | grep -v '('
e2fsprogs.out                                         0 s /nix/store/ghnqs6bfidr7g3i0y91kibh6f52i51q5-e2fsprogs-1.46.2/lib/libcom_err.so.2
e2fsprogs.out                                    22,608 x /nix/store/ghnqs6bfidr7g3i0y91kibh6f52i51q5-e2fsprogs-1.46.2/lib/libcom_err.so.2.1

(The grep -v '(' is used to remove a bunch (130) of “indirect” providers)

2 Likes

Does nix-index/nix-locate work on packages that I do not have in my local /nix/store?

Yes, that’s its purpose.

You need to build an initial DB using nix-index which will query hydra for path contents and write it to disk. On my machine with my internet connection this took 10 minutes and the file has a size of ~43 MiB.

After that you can use nix-locate to query the database.

I usually rebuild the DB once in a while, roughly after a new release, or whenever I have searched something where I know it has to be there (as I use it already) but nothing was found.

1 Like

Hmm, I usually make do with just find for those things. I really need a solution for packages that I don’t have in my own personal /nix/store.

So use nix-index, it even tells you the attribute name.

Oh sorry I totally misread! It’s late here haha…

A nix-index data is continuously updated at GitHub - Mic92/nix-index-database: Weekly updated nix-index database. You can follow the description there to just copy the file in place so it works with nix-locate or set it to update automatically.

3 Likes