nix-community / NixOS-WSL

NixOS on WSL(2) [maintainer=@nzbr]
Apache License 2.0
1.79k stars 114 forks source link

21.11-d89f18a1 fails after initial import with `nsenter: failed to parse pid: '-p'` #67

Closed erik-smit closed 2 years ago

erik-smit commented 2 years ago

This is on a Dell Latitude 7320 with Windows 11 fresh from the box.

Ubuntu on WSL works fine.

Import goes fine. First run gives An error occurred mounting one of your file systems. Please run 'dmesg' for more details. but continues installation. Second run exits with An error occurred mounting one of your file systems. Please run 'dmesg' for more details. nsenter: failed to parse pid: '-p'.

I'll see if I can troubleshoot what's going on. I suspect it may be behind on updates. I'll update it and report back. If the updates fix it, I'll close the issue and hopefully somebody else who runs into this issue is helped by this.

PS C:\Users\erik.smit.ALETHO\Downloads> wsl --unregister NixOS
Unregistering...
PS C:\Users\erik.smit.ALETHO\Downloads> wsl --import NixOS .\NixOS\ nixos-wsl-installer.tar.gz --version 2
PS C:\Users\erik.smit.ALETHO\Downloads> wsl -d NixOS
An error occurred mounting one of your file systems. Please run 'dmesg' for more details.
Unpacking root file system...
 184MiB 0:00:15 [11.8MiB/s] [========================================================================================================================================================================================================================================>] 100%
Activating nix configuration...
Copying /usr/share/applications
Copying /usr/share/icons
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
setting up /etc...
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Cleaning up installer files...
finding garbage collector roots...
removing stale link from '/nix/var/nix/gcroots/auto/6yfbrv8wfkyl40wq6827lamr9m29z7wg' to '/build/nix/var/nix/profiles/per-user/root/channels-1-link'
removing stale link from '/nix/var/nix/gcroots/auto/zxi8v969la5n36bg7gs016wgcif4qjhp' to '/build/nix/var/nix/profiles/system-1-link'
deleting garbage...
deleting '/nix/store/svw89j47vr3h792f75nfgh5x9s48rn0w-pv-1.6.20'
deleting '/nix/store/m0qmllywgy9wl4ia7vvpz7p53kzxv681-busybox-1.34.1'
deleting '/nix/store/m7cghw288wks5s5mkxpg1k3h5ivlg1ch-installer.sh'
deleting '/nix/store/8hm7r6m8y0fjrb4qjv8gs1ba04g51166-tarball'
deleting '/nix/store/y608sw04xdqhha69raxpj2rsk007n7wf-wsl-prepare'
deleting '/nix/store/4ryxif8fmjb362ry8ylx29hsxp0zgpax-source'
deleting '/nix/store/trash'
deleting unused links...
note: currently hard linking saves -0.00 MiB
6 store paths deleted, 185.42 MiB freed
Optimizing store...
5.05 MiB freed by hard-linking 3499 files
Starting systemd...
PS C:\Users\erik.smit.ALETHO\Downloads> wsl -d NixOS
An error occurred mounting one of your file systems. Please run 'dmesg' for more details.
nsenter: failed to parse pid: '-p'
PS C:\Users\erik.smit.ALETHO\Downloads> wsl --unregister NixOS
Unregistering...
PS C:\Users\erik.smit.ALETHO\Downloads> wsl --import NixOS .\NixOS\ nixos-wsl-installer.tar.gz --version 2
PS C:\Users\erik.smit.ALETHO\Downloads> wsl -d NixOS
An error occurred mounting one of your file systems. Please run 'dmesg' for more details.
Unpacking root file system...
 184MiB 0:00:12 [14.9MiB/s] [========================================================================================================================================================================================================================================>] 100%
Activating nix configuration...
Copying /usr/share/applications
Copying /usr/share/icons
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
setting up /etc...
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Cleaning up installer files...
finding garbage collector roots...
removing stale link from '/nix/var/nix/gcroots/auto/6yfbrv8wfkyl40wq6827lamr9m29z7wg' to '/build/nix/var/nix/profiles/per-user/root/channels-1-link'
removing stale link from '/nix/var/nix/gcroots/auto/zxi8v969la5n36bg7gs016wgcif4qjhp' to '/build/nix/var/nix/profiles/system-1-link'
deleting garbage...
deleting '/nix/store/svw89j47vr3h792f75nfgh5x9s48rn0w-pv-1.6.20'
deleting '/nix/store/m0qmllywgy9wl4ia7vvpz7p53kzxv681-busybox-1.34.1'
deleting '/nix/store/m7cghw288wks5s5mkxpg1k3h5ivlg1ch-installer.sh'
deleting '/nix/store/8hm7r6m8y0fjrb4qjv8gs1ba04g51166-tarball'
deleting '/nix/store/y608sw04xdqhha69raxpj2rsk007n7wf-wsl-prepare'
deleting '/nix/store/4ryxif8fmjb362ry8ylx29hsxp0zgpax-source'
deleting '/nix/store/trash'
deleting unused links...
note: currently hard linking saves -0.00 MiB
6 store paths deleted, 185.42 MiB freed
Optimizing store...
5.05 MiB freed by hard-linking 3499 files
Starting systemd...
PS C:\Users\erik.smit.ALETHO\Downloads> wsl -d NixOS
An error occurred mounting one of your file systems. Please run 'dmesg' for more details.
nsenter: failed to parse pid: '-p'
PS C:\Users\erik.smit.ALETHO\Downloads>
erik-smit commented 2 years ago

This nsenter: failed to parse pid: '-p' only occurs with the latest release 21.11-d89f18a1.

20.09-1c1f5649 works.

PS C:\Users\erik.smit.ALETHO\Downloads> wsl --distribution NixOS
An error occurred mounting one of your file systems. Please run 'dmesg' for more details.

[nixos@nixos:/mnt/c/Users/erik.smit.ALETHO/Downloads]$

Seems like the An error occurred mounting one of your file systems. Please run 'dmesg' for more details. is a red herring and a separate issue.

erik-smit commented 2 years ago

Rebooting or terminating the instance after importing 'solves' the problem.

It looks like the installer leaves the system in a bad state.

PS C:\Users\erik.smit.ALETHO> wsl -d NixOS
An error occurred mounting one of your file systems. Please run 'dmesg' for more details.
nsenter: failed to parse pid: '-p'
PS C:\Users\erik.smit.ALETHO> wsl -t NixOS
PS C:\Users\erik.smit.ALETHO> wsl -d NixOS
Copying /usr/share/applications
Copying /usr/share/icons
setting up /etc...

[nixos@Budapest:/mnt/c/Users/erik.smit.ALETHO]$
nzbr commented 2 years ago

The "An error occurred mounting one of your file systems. Please run 'dmesg' for more details." on first launch can be safely ignored. It should not happen after the installer has ran though. It happens because there is no /bin/mount present in the installer image.

You should not drop back to powershell after the installer finishes, instead a bash should open. There was an issue that caused the activation script to fail on the first start. I have pushed a fix for that issue and moved the release to that commit. The issue might be that you have a copy of the installer tarball that does not contain the fix. Can you give me the timestamp of the tarball you downloaded?

erik-smit commented 2 years ago
smite@Budapest:/mnt/c/Users/erik.smit.ALETHO/Downloads$ md5sum nixos-wsl-installer.tar.gz
d0f5078b774229964b88d1aa526819e5  nixos-wsl-installer.tar.gz
smite@Budapest:/mnt/c/Users/erik.smit.ALETHO/Downloads$ ls -la nixos-wsl-installer.tar.gz
-rwxrwxrwx 1 smite smite 203271183 Mar 31 14:36 nixos-wsl-installer.tar.gz
nzbr commented 2 years ago

The file you have contains the fix. That means there is another problem here EDIT: I can reproduce the issue on my setup

nzbr commented 2 years ago

The problem was introduced by a change from #64. The commit just before it was merged works just fine

nzbr commented 2 years ago

I have created a PR that should fix the issue. The CI should have built a tarball soon, so you can try if it works

https://github.com/nix-community/NixOS-WSL/suites/5882551859/artifacts/198820817

erik-smit commented 2 years ago

Solves the problem for me. Thank you!

nixos-discourse commented 1 year ago

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

https://discourse.nixos.org/t/nixos-wsl-2-error-with-22-05-5c211b47-nsenter-failed-to-parse-pid-p/24238/1