Open 573 opened 2 months ago
When following https://github.com/nix-community/NixOS-WSL/issues/292#issue-1904936552 for recovery it fails at step nix-channel --update
:
unpacking channels... error: … while setting up the build environment
error: getting attributes of path '/run/binfmt': No such file or directory
error: program '/nix/store/mi3yg271xmvsi8832vpl562hv1mh76gg-nix-2.20.8/bin/nix-env' failed with exit code 1
Recovery also not possible:
error: file 'nixos-wsl/modules' was not found in the Nix search path (add it using $NIX_PATH or -I)
at «none»:0: (source not available)
All found here suggests nix-channel --update
so full circle.
Workaroud hack: sudo mkdir /run/binfmt
and after that I repeated the original, my regular nixos-rebuild
command, with the offending boot.binfmt.emulatedSystems = [ "aarch64-linux" ];
line factored out from my configuration.nix.
Marked hack
because I still assume that I can log in to my existing install to do that.
The recovery steps still are not useable as long as I do not log in to the freshly built generation and revive via nix-channel --update
, hopefully working this time. What might work beforehand was trying to built my config closure from the recovery env somehow, but I don't have time to check on that precautiously now.
~-Also, sudo systemctl status wsl-binfmt
still has~
~...~
EDIT: nixos-rebuild switch
mitigates last comment's issue.
What do you have set for wsl.interop.register and boot.binfmt.registrations?
wsl.interop.register = true;
and boot.binfmt.registrations
probably only the default - did not set (only boot.binfmt.emulatedSystems = [ "aarch64-linux" ];
).
This is what I have now (workaround as stated), not clear what belongs there with emulatedSystems = [ "aarch64-linux" ];
:
nix-repl> :p nixosConfigurations.DANIELKNB1.config.boot.binfmt.emulatedSystems [ ] nix-repl> :p nixosConfigurations.DANIELKNB1.config.boot.binfmt.registrations { WSLInterop = { fixBinary = true; interpreter = "/init"; interpreterSandboxPath = null; magicOrExtension = "MZ"; mask = null; matchCredentials = false; offset = null; openBinary = false; preserveArgvZero = true; recognitionType = "magic"; wrapInterpreterInShell = false; }; }
With
nix-repl> :p nixosConfigurations.DANIELKNB1.config.boot.binfmt.emulatedSystems [ "aarch64-linux" ]
nix-repl> :p nixosConfigurations.DANIELKNB1.config.boot.binfmt.registrations { WSLInterop = { fixBinary = true; interpreter = "/init"; interpreterSandboxPath = null; magicOrExtension = "MZ"; mask = null; matchCredentials = false; offset = null; openBinary = false; preserveArgvZero = true; recognitionType = "magic"; wrapInterpreterInShell = false"/nix/store/y1qhdk8ijklin832w0vl9ak7dmll0flh-qemu-aarch64-binfmt-P-x86_64-unknown-linux-musl/bin/qemu-aarch64-binfmt-P"; interpreterSandboxPath = "/nix/store/y1qhdk8ijklin832w0vl9ak7dmll0flh-qemu-aarch64-binfmt-P-x86_64-unknown-linux-musl"; magicOrExtension = "\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00"; mask = "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\x00\xff\xfe\xff\xff\xff"; matchCredentials = false; offset = null; openBinary = false; preserveArgvZero = true; recognitionType = "magic"; wrapInterpreterInShell = false; }; }
building the system configuration... activating the configuration... setting up /run/booted-system... setting up /etc... setting up /bin... setting up /bin/login... setting up /sbin/init shim... reloading user units for nixos... restarting sysinit-reactivation.target reloading the following units: dbus.service restarting the following units: home-manager-nixos.service, home-manager-root.service the following new units were started: local-fs.target, sysinit-reactivation.target, systemd-timesyncd.service, systemd-tmpfiles-resetup.service, systemd-tmpfiles-setup.service warning: the following units failed: systemd-binfmt.service
× systemd-binfmt.service - Set Up Additional Binary Formats Loaded: loaded (/etc/systemd/system/systemd-binfmt.service; enabled; preset: enabled) Drop-In: /nix/store/k34v5qxbjw6braddfasf3591immcsfv5-system-units/systemd-binfmt.service.d └─overrides.conf Active: failed (Result: exit-code) since Wed 2024-10-02 12:08:19 CEST; 100ms ago Docs: man:systemd-binfmt.service(8) man:binfmt.d(5) https://docs.kernel.org/admin-guide/binfmt-misc.html https://www.freedesktop.org/wiki/Software/systemd/APIFileSystems Process: 148180 ExecStart=/nix/store/nswmyag3qi9ars0mxw5lp8zm0wv5zxld-systemd-255.9/lib/systemd/systemd-binfmt (code=exited, status=1/FAILURE) Main PID: 148180 (code=exited, status=1/FAILURE) IP: 0B in, 0B out
Oct 02 12:08:19 sis systemd-binfmt[148180]: /etc/binfmt.d/nixos.conf:1: Failed to add binary format 'WSLInterop': No such file or directory warning: error(s) occurred while switching to the new configuration
$ cat /etc/binfmt.d/nixos.conf :WSLInterop:M::MZ::/run/binfmt/WSLInterop:PF
Bug description
nix develop
and certain other commands always state:To Reproduce
Steps to reproduce the behavior:
Run
nix develop nixpkgs#hello
Logs
Sep 24 09:39:19 DANIELKNB1 systemd-binfmt[20623]: /etc/binfmt.d/nixos.conf:1: Failed to add binary format 'WSLInterop': No such file or directory
○ wsl-binfmt.service - WSL binfmt restore Loaded: loaded (/run/systemd/generator.early/wsl-binfmt.service; generated) Active: inactive (dead) since Tue 2024-09-24 09:38:50 CEST; 9min ago Process: 20574 ExecStart=/bin/sh -c (echo -1 > /proc/sys/fs/binfmt_misc/WSLInterop-late) ; (echo :WSLInterop-late:M::MZ::/init:P > /proc/sys/fs/binfmt_misc/register) (code=exited, status=0/SUCCESS) Main PID: 20574 (code=exited, status=0/SUCCESS) IP: 0B in, 0B out
Sep 24 09:38:50 DANIELKNB1 sh[20575]: /nix/store/nmyaxjl9ihqf3d7b3i60x1mj000rvm35-bash-interactive-5.2p32/bin/sh: line 1: /proc/sys/fs/binfmt_misc/WSLInterop-late: Permission denied
WSL-Version: 2.2.4.0 Kernelversion: 5.15.153.1-2 WSLg-Version: 1.0.61 MSRDC-Version: 1.2.5326 Direct3D-Version: 1.611.1-81528511 DXCore-Version: 10.0.26091.1-240325-1447.ge-release Windows-Version: 10.0.19045.4780