Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: could not dynamically open plugin file … libnix_doc_plugin.so #237637

Closed
tdillenburg opened this issue Jun 13, 2023 · 6 comments · Fixed by #248998
Closed

error: could not dynamically open plugin file … libnix_doc_plugin.so #237637

tdillenburg opened this issue Jun 13, 2023 · 6 comments · Fixed by #248998

Comments

@tdillenburg
Copy link

When trying to switch to a new generation, nixos-rebuild switch --flake '.#' throws this error:

error: could not dynamically open plugin file '/nix/store/458wmvsdw95kd96j88gnhjc6a38hq8aw-nix-doc-0.5.8/lib/libnix_doc_plugin.so': /nix/store/458wmvsdw95kd96j88gnhjc6a38hq8aw-nix-doc-0.5.8/lib/libnix_doc_plugin.so: undefined symbol: _ZN3nix9EvalState14throwEvalErrorENS_6PosIdxEPKc
Traceback (most recent call last):
  File "/nix/store/8c27ljrks2590wmdr1pcg3a7l3j4nhxm-systemd-boot", line 341, in <module>
    main()
  File "/nix/store/8c27ljrks2590wmdr1pcg3a7l3j4nhxm-systemd-boot", line 292, in main
    gens = get_generations()
  File "/nix/store/8c27ljrks2590wmdr1pcg3a7l3j4nhxm-systemd-boot", line 160, in get_generations
    gen_list = subprocess.check_output([
  File "/nix/store/6qk2ybm2yx2dxmx9h4dikr1shjhhbpfr-python3-3.10.11/lib/python3.10/subprocess.py", line 421, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/nix/store/6qk2ybm2yx2dxmx9h4dikr1shjhhbpfr-python3-3.10.11/lib/python3.10/subprocess.py", line 526, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/nix/store/k6ciawnknm1yxxiwm4pih008rijyn9wh-nix-2.15.1/bin/nix-env', '--list-generations', '-p', '/nix/var/nix/profiles/system', '--option', 'build-users-group', '']' returned non-zero exit status 1.
warning: error(s) occurred while switching to the new configuration

Apparently it's an issue with nix-doc. In nix-doc issue 20, the author suggests overriding nix but it didn't work. It seams like nix got corrupted.

This is pointed as a risk at nix documentation:

Warning! These APIs are inherently unstable and may change from release to release.
Since these files are loaded into the same address space as Nix itself, they must be DSOs compatible with the instance of Nix running at the time (i.e. compiled against the same headers, not linked to any incompatible libraries). They should not be linked to any Nix libs directly, as those will be available already at load time.

I've tryed removing nix-doc and nix.extraOptions = "plugin-files = ${pkgs.nix-doc}/lib/libnix_doc_plugin.so"; but the error perssists and nixos can't switch to the new generations.

I can't edit /etc/nix/nix.conf as it's linked so I can't manually remove the line:
plugin-files = /nix/store/458wmvsdw95kd96j88gnhjc6a38hq8aw-nix-doc-0.5.8/lib/libnix_doc_plugin.so

Steps To Reproduce

Steps to reproduce the behavior:

  1. add environment.systemPackages = pkgs.nix-doc; and nix.extraOptions = "$plugin-files = ${pkgs.nix-doc}/lib/libnix_doc_plugin.so"; to configuration.nix
  2. nixos-rebuild switch or nixos-rebuild boot
  3. nixos-rebuild is not longer working

Expected behavior

There should be a way to unlink dynamic libraries linked to nix cli during build time.

Notify maintainers

@lf-

Metadata

I can't run nix-shell -p nix-info --run "nix-info -m".

nixos-version: 23.11.20230606.4729ffa (Tapir)
nix --version was 2.13.1, but it throws error now

@kirillrdy
Copy link
Member

greetings @tdillenburg

Is my understanding correct

  • you had previously nix.extraOptions = "plugin-files = ${pkgs.nix-doc}/lib/libnix_doc_plugin.so"; in your nixos configuration ?
  • after recent upgrade nix commands eg nix-env dont work because of ABI incompatibility when it tries to load nix-doc?

if that's the case, and we are confident that removing plugin-files = ${pkgs.nix-doc}/lib/libnix_doc_plugin.so from nix.conf will solve the issue, then you can just copy the nix.conf over that symlink and edit it manually.

cd /etc/nix
sudo rm nix.conf 
sudo cp /etc/static/nix/nix.conf .
ls
sudo nvim nix.conf   # or editor of your choice, the file is read only so you will need to use `:w!` for neovim

If that fixes nix, the after next nixos-rebuild /etc/nix/nix.conf will be restored to correct symlink

Hopefully this helps

@lf-
Copy link
Member

lf- commented Jun 14, 2023

I have a hunch as to why this is happening: most likely you're using a newer version of Nix to build your configuration (the default behaviour of nixos-rebuild is to reexec Nix of the version from the new config but probably not with the new nix.conf from the config (bug??)) and so that newer version of Nix is being used with the old nix.conf to build the new NixOS config.

It's plausible that you can avoid this by either using --fast with nixos-rebuild to disable such reexec or pass --plugin-files "" to Nix to fix it temporarily (although you would have to read the nixos-rebuild sources to figure out how).

I believe that this problem is sadly unavoidable without somehow detecting linker errors and bailing on the dynamic library loading, which, maybe that's possible but I doubt it.

@tdillenburg
Copy link
Author

Thank you @kirillrdy. It worked perfectly. I didn't know nix kept a static version of files and that I could simply replace it. Without the plugin-files line nixos-rebuild worked.

@lf-, it's weird because I had nix-doc for a long time in my config but it just "broke" now. Well, I'm not sure why it broke, but the workarround worked. Thanks!

@lf-
Copy link
Member

lf- commented Jun 14, 2023

Nix has not had many updates in nixpkgs as of late. That is my best guess as to cause. Either way, I'm glad you got it fixed. nix-doc should work with the latest Nix once you have your config rebuilt successfully.

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2023-07-24-nix-team-meeting-minutes-75/31112/2

lf- added a commit to lf-/nixpkgs that referenced this issue Aug 14, 2023
Fixes NixOS#237637 and its entire
class of problems by making nix-doc save the version it was built for in
the library and then bail harmlessly if it is mismatched.

```
dev/nixpkgs2 » nix-build -A nix-doc
/nix/store/wv9nm47lplyz4b0pa4549zwrnsp3zvaf-nix-doc-0.5.10
dev/nixpkgs2 » nix-build -A nixVersions.nix_2_14 -o result2
/nix/store/ka0ygdzl9jd0j77y7ls6shngdz9vvqpn-nix-2.14.1
dev/nixpkgs2 » ./result2/bin/nix --plugin-files ./result/lib/libnix_doc_plugin.so repl
nix-doc warning: mismatched nix version, not loading
Welcome to Nix 2.14.1. Type :? for help.

nix-repl>
```
lf- added a commit to lf-/nixpkgs that referenced this issue Aug 14, 2023
Fixes NixOS#237637 and its entire
class of problems by making nix-doc save the version it was built for in
the library and then bail harmlessly if it is mismatched.

```
dev/nixpkgs2 » nix-build -A nix-doc
/nix/store/wv9nm47lplyz4b0pa4549zwrnsp3zvaf-nix-doc-0.5.10
dev/nixpkgs2 » nix-build -A nixVersions.nix_2_14 -o result2
/nix/store/ka0ygdzl9jd0j77y7ls6shngdz9vvqpn-nix-2.14.1
dev/nixpkgs2 » ./result2/bin/nix --plugin-files ./result/lib/libnix_doc_plugin.so repl
nix-doc warning: mismatched nix version, not loading
Welcome to Nix 2.14.1. Type :? for help.

nix-repl>
```
zowoq pushed a commit that referenced this issue Aug 15, 2023
Fixes #237637 and its entire
class of problems by making nix-doc save the version it was built for in
the library and then bail harmlessly if it is mismatched.

```
dev/nixpkgs2 » nix-build -A nix-doc
/nix/store/wv9nm47lplyz4b0pa4549zwrnsp3zvaf-nix-doc-0.5.10
dev/nixpkgs2 » nix-build -A nixVersions.nix_2_14 -o result2
/nix/store/ka0ygdzl9jd0j77y7ls6shngdz9vvqpn-nix-2.14.1
dev/nixpkgs2 » ./result2/bin/nix --plugin-files ./result/lib/libnix_doc_plugin.so repl
nix-doc warning: mismatched nix version, not loading
Welcome to Nix 2.14.1. Type :? for help.

nix-repl>
```
a-kenji pushed a commit to a-kenji/nixpkgs that referenced this issue Aug 21, 2023
Fixes NixOS#237637 and its entire
class of problems by making nix-doc save the version it was built for in
the library and then bail harmlessly if it is mismatched.

```
dev/nixpkgs2 » nix-build -A nix-doc
/nix/store/wv9nm47lplyz4b0pa4549zwrnsp3zvaf-nix-doc-0.5.10
dev/nixpkgs2 » nix-build -A nixVersions.nix_2_14 -o result2
/nix/store/ka0ygdzl9jd0j77y7ls6shngdz9vvqpn-nix-2.14.1
dev/nixpkgs2 » ./result2/bin/nix --plugin-files ./result/lib/libnix_doc_plugin.so repl
nix-doc warning: mismatched nix version, not loading
Welcome to Nix 2.14.1. Type :? for help.

nix-repl>
```
@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/libnix-doc-plugin-so-is-putting-me-in-an-upgrade-deadlock/32647/4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants