NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.71k stars 13.84k forks source link

NixOS system misconfiguration: ldconfig -p has exit status 1 #35387

Open coretemp opened 6 years ago

coretemp commented 6 years ago

Issue description

As root:

# ldconfig -p
ldconfig: Can't open cache file /nix/store/xzx1bv1d7z4mgg6sg6ly0jx609qvka4x-glibc-2.25-49/etc/ld.so.cache
: No such file or directory
# echo $?
1

I expect no error message and an exit status of 0.

Technical details

abbradar commented 6 years ago

It's arguably the correct behaviour because there's no ld.cache in NixOS at all, hence failure.

coretemp commented 6 years ago

The correct behavior to me seems to be to output nothing and exit with EXIT_SUCCESS.

-p

Print the lists of directories and candidate libraries stored in the current cache.
abbradar commented 6 years ago

There is a difference between "empty cache" and "no cache" though and we have the second case -- I don't think changing behaviour of ldconfig is a good idea. We could add an empty cache but is there any merit to it?

coretemp commented 6 years ago

I am also not sure what's best. I do know that if NixOS would be the only operating system in the world, that we would just delete the -p flag from ldconfig.

Back in the real world lots of scripts seem to use the -p flag, although generally these scripts will only work on a single operating system anyway.

Result from searching for "ldconfig -p" on GitHub.

13,033 code results

Since technically the current cache is undefined, ldconfig -p has https://en.wikipedia.org/wiki/Undefined_behavior and its current behavior (exiting with exitstatus 1) is valid too.

It would be nicer to have an empty cache, because then the program has no source of undefined behavior anymore.

abbradar commented 6 years ago

What is this call usually used for? To enumerate library directories? If so we could emulate it in our stdenv just for builds (though I'm not sure we want this instead of patching packages and telling upstream to fix their stuff).

bbarker commented 5 years ago

I'm also having the issue on one of my systems. Oddly it occurs when running stack --nix build, which i've certainly run on other NixOS systems (albeit maybe slightly different versions).

[nix-shell:/opt/purescript-dynlangs]$ ldconfig -p                                                                                                                                                                                                                                                                                                                          │·······························································
ldconfig: Can't open cache file /nix/store/7gx4kiv5m0i7d7qkixq2cwzbr10lvxwc-glibc-2.27/etc/ld.so.cache                                                                                                                                                                                                                                                                     │·······························································
: No such file or directory                                                                                                                                                                                                                                                                                                                                                │·······························································                                                                                                                                                                                                                                                                                                                                                                           │·······························································
[nix-shell:/opt/purescript-dynlangs]$ stack --nix build                                                                                                                                                                                                                                                                                                                    │·······························································
/nix/store/8bh94qdmga1zkb85li56380i44ay82cs-glibc-2.27-bin/bin/ldconfig: Can't open cache file /nix/store/7gx4kiv5m0i7d7qkixq2cwzbr10lvxwc-glibc-2.27/etc/ld.so.cache                                                                                                                                                                                                      │·······························································
: No such file or directory                                                                                                                                                                                                                                                                                                                                                │·······························································I don't know how to install GHC on your system configuration, please install manually

My system info:

flokli commented 4 years ago

@bbarker did you dig through stack on what it uses ldconfig -p for?

stale[bot] commented 4 years ago

Thank you for your contributions. This has been automatically marked as stale because it has had no activity for 180 days. If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity. Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse. 3. Ask on the #nixos channel on irc.freenode.net.
uri-canva commented 3 years ago

We are also hitting this issue with playwright, which uses ldconfig -p to provide the user with an error message suggesting how to install missing dependencies: https://github.com/aslushnikov/playwright/blob/2ac93f0a8bd61bdd7920629d9560e40ff1f15506/src/server/validateDependencies.ts

Reported on playwright as well: https://github.com/microsoft/playwright/issues/5501.

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

thinkrapido commented 2 years ago

It is also not working for python's Nuitka

https://github.com/Nuitka/Nuitka/issues/1520

danielmain commented 2 years ago

Same here 😞

➜ ~ lutris /run/current-system/sw/bin/ldconfig: Can't open cache file /nix/store/d2bpliayddadf6lx6l1i04w265gqw8n6-glibc-2.34-210/etc/ld.so.cache : No such file or directory 2022-07-02 08:02:19,615: ['/run/current-system/sw/bin/ldconfig', '-p'] command failed: Command '['/run/current-system/sw/bin/ldconfig', '-p']' returned non-zero exit status 1. 2022-07-02 08:02:19,839: Starting Lutris 0.5.10.1

bugeats commented 2 years ago

Tensorflow CUDA config scripts currently use ldconfig -p and break tensorflow-sys builds in NixOS.

flokli commented 2 years ago

Tensorflow CUDA config scripts currently use ldconfig -p and break tensorflow-sys builds in NixOS.

This line probably needs to be changed in NixOS, to look from a hard coded path.

https://github.com/tensorflow/tensorflow/blob/f4dac8ea5e9262912ac809f719ef58b5e312b98f/third_party/gpus/find_cuda_config.py#L166

bugeats commented 2 years ago

This line probably needs to be changed

I mean, yes, maybe? The way I read this particular script is that it will work fine in NixOS just as long as the call to ldconfig -p doesn't return an error. I suspect it's the same for all the other external projects mentioned in this issue.

FWIW, I think that @abbradar had the right idea. An empty ld.so.cache should do the trick. I also think it's arguable the semantically correct thing to do. In the context of NixOS, all cache queries should be misses.