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

nsenter: failed to parse pid: '-p' on a previously working installation #533

Closed
harryaskham opened this issue Aug 27, 2024 · 6 comments
Closed
Labels
bug Something isn't working

Comments

@harryaskham
Copy link

harryaskham commented Aug 27, 2024

Similar issue to e.g. #67 except I have only found records of this issue happening on fresh installations, with advice to reinstall with a fixed installer. This started happening on a NixOS WSL installation that's been working fine since 2022-11-06.

The system follows unstable. I had a few-days-old nixos-rebuild switch --upgrade which I discounted as the culprit due to it working fine since, but WSL had been up since and hadn't had to boot until now. Rolling back has fixed it (while I was writing this up - leaving this as I'd have found it useful when searching the issue), but given this system can't --upgrade without issue I'll reinstall from a newer base.


On booting Win11 and opening a WSL term, the first session hangs on systemd launch:

Copying /usr/share/applications
Copying /usr/share/icons
warning: not applying UID change of user ‘harry’ (1001 -> 1000) in /etc/passwd
setting up /etc...
setting up /bin...
Starting systemd...

This is not new and has been happening since system installation. Usually the second session boots.
Now though opening the second+ session gives:

nsenter: failed to parse pid: '-p'

[process exited with code 1 (0x00000001)]

No amount of Win11 rebooting or wsl --shutdown fixes this.

I can reach a shell via:

PS C:\Users\harry> wsl -d nixos -e sh
sh-5.2# /nix/var/nix/profiles/system/activate
...
sh-5.2# source /etc/set-environment
...
root@nixos:/mnt/c/Users/harry/ >

and if I then run

root@nixos:/mnt/c/Users/harry/ > echo -n "1" >> /var/run/systemd.pid

I can open a regular WSL session and it'll log in fine. Ultimately this let me roll back a couple of generations before the --upgrade.

journalctl -b shows the following on the successful session login:

Aug 27 08:48:10 rog-win11 systemd[593]: Failed to attach 593 to compat systemd cgroup /user.slice/user-1001.slice/user@1001.service/init.scope: Permission denied
Aug 27 08:48:10 rog-win11 systemd[1]: Incoming private connection from unprivileged client, refusing: No data available

I don't have any journal entries before the sh fallback session (i.e. the nsenter -p failed attempts).

@harryaskham harryaskham added the bug Something isn't working label Aug 27, 2024
@SuperSandro2000
Copy link
Member

Are you using native systemd?

@harryaskham
Copy link
Author

harryaskham commented Aug 27, 2024

I hadn't touched anything systemd-related myself, either in WSL2 or NixOS, but I don't know what's happening transitively. So however WSL would have been configured late 2022 is at least how the system started out. I've been running tailscale as tailscaled.service in it for some time i.e. before the current systemd setup in NixOS-WSL.

I get a 160K line nix-diff of the generations either side of the nixos-switch --upgrade - amongst other things, it upgrades systemd{-minimal{-libs}} from 255.6 to 256.4. Not familiar enough with systemd to know whether this counts as native.

@SuperSandro2000
Copy link
Member

SuperSandro2000 commented Aug 27, 2024

@harryaskham
Copy link
Author

Got you, thanks for the pointers. I did try to manually edit this into /etc/wsl.conf but found it's actually managed by NixOS; in any case I'm too far behind to use this, The option wsl.nativeSystemd' does not exist.`. I might be able to update the NixOS-WSL machinery separately to the otherwise breaking upgrade that borks the system, but I'll probably just clean install at this point.

@nzbr
Copy link
Member

nzbr commented Sep 2, 2024

There is a good chance you will be able to rescue it by doin the things in the Migrating from 22.05 releases section on the 23.05.5 release. By doing that you will add this repo as a channel, so you will get the latest NixOS-WSL code, not actually the release from back then. It just happens to be the one where we changed the delivery method

@harryaskham
Copy link
Author

Oh, perfect, that's exactly what I needed. The 23.05 upgrade process fixed the issue without needing a WSL-level reinstall. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants