microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.44k stars 821 forks source link

error after wsl update: getpwnam(username) failed 0 #9340

Closed rbavery closed 1 year ago

rbavery commented 1 year ago

Version

Microsoft Windows [Version 10.0.19044.2364]

WSL Version

Kernel Version

Ubuntu Version 2

Distro Version

20.04

Other Software

WSL asked me to do an update saying WSL was now on the microsoft store when I opened windows terminal that opens my Ubuntu that is powered by wsl.

so I ran wsl.exe --update or something like it (cmd doesn't go back in history after closing the terminal)

now I get a message whenever I open windows terminal (that opens ubuntu)

<3>WSL (191) ERROR: CreateProcessEntryCommon:345: getpwnam(rave) failed 0

this is still the case after a restart. I searched other issue son this repo but I haven't found it.

this issue wasn't the case for me, my default is Ubuntu not docker: https://askubuntu.com/questions/1423048/i-am-getting-error-on-windows-subsystem

Repro Steps

update wsl from wsl preview using the suggested command line step that pops up when you open windows terminal

Expected Behavior

no error pop up

Actual Behavior

error pops up

<3>WSL (191) ERROR: CreateProcessEntryCommon:345: getpwnam(rave) failed 0
(base)
# root at rave in ~ [12:35:47]
→ ls

Diagnostic Logs

No response

elsaco commented 1 year ago

@rbavery that looks like a user not found type of error. Can you please try root instead:

wsl -d Ubuntu-20.04 -u root

and fix the user issue after successful WSL distro start.

bkraul commented 1 year ago

Check your /etc/wsl.conf to see if you are referencing a default user that doesn't exist. That's what was happening with mine. I had renamed the default user in the installation but forgot to update in wsl.conf.

chaffees commented 1 year ago

@bkraul that worked for me. After the update, I edited the /etc/wsl.conf file and added my username. You can use the command 'whoami' to find the username that should be updated in the 'wsl.conf' file.

rbavery commented 1 year ago

I still have this error, thanks for the feedback all.

I get this error when running

PS C:\Users\Ryan> wsl -d Ubuntu-20.04 -u root
There is no distribution with the supplied name.
Error code: Wsl/Service/WSL_E_DISTRO_NOT_FOUND

but in my wsl ubuntu shell I get

# root at rave in ~ [13:39:26]
→ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.5 LTS
Release:        20.04
Codename:       focal

the wsl.conf shows

[user]
default=rave

it looks like this user doesn't exist after the wsl update for some reason

# root at rave in ~ [13:43:51]
→ cut -d: -f1 /etc/passwd
root
daemon
bin
sys
sync
games
man
lp
mail
news
uucp
proxy
www-data
backup
list
irc
gnats
nobody
systemd-network
systemd-resolve
systemd-timesync
messagebus
syslog
_apt
tss
uuidd
tcpdump
sshd
landscape
pollinate
dnsmasq

but when I set my wsl.conf to the root user, I still get the error message

<3>WSL (23176) ERROR: CreateProcessEntryCommon:355: getpwnam(rave) failed 0
bkraul commented 1 year ago

I still have this error, thanks for the feedback all.

I get this error when running

PS C:\Users\Ryan> wsl -d Ubuntu-20.04 -u root
There is no distribution with the supplied name.
Error code: Wsl/Service/WSL_E_DISTRO_NOT_FOUND

but in my wsl ubuntu shell I get

# root at rave in ~ [13:39:26]
→ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.5 LTS
Release:        20.04
Codename:       focal

the wsl.conf shows

[user]
default=rave

it looks like this user doesn't exist after the wsl update for some reason

# root at rave in ~ [13:43:51]
→ cut -d: -f1 /etc/passwd
root
daemon
bin
sys
sync
games
man
lp
mail
news
uucp
proxy
www-data
backup
list
irc
gnats
nobody
systemd-network
systemd-resolve
systemd-timesync
messagebus
syslog
_apt
tss
uuidd
tcpdump
sshd
landscape
pollinate
dnsmasq

but when I set my wsl.conf to the root user, I still get the error message

<3>WSL (23176) ERROR: CreateProcessEntryCommon:355: getpwnam(rave) failed 0

Did you do a wsl --shutdown on the Windows Command Prompt after you set the default user to root?

rbavery commented 1 year ago

That worked! thank you for the incredibly timely help @bkraul

godstargod commented 1 year ago

ok for kali user there is a simpler way to fix this , i personally think import function is bs now because of this , hear these steps should work for you too on ubuntoo just adapt the directory

P> after import i get this an no way to break for the pawnam() error

SOL1> so i unregistered it , SOL2> went and install kali from store , once i was in my user again , SOL3> i opened a shell cmd , wsl --shutdown SOL4 > copied my old ext4.vhxd backup not the import over the one in c:\Users\~\AppData\Local\Packages\KaliLinux.54290C8133FEE_ey8k8hqnwqnmg\LocalState\ext4.vhxd over the new one. 5> click the kali icon and enjoy not seeing the pawnam(user)error voila , no need for ms wall of text adventures that takes an evening or more for nothing when you can just paste over. DIRECTLY

should work the same with other flavours of wsl, just adapt the destinations . ive rebuild my computer and this solution is the best as i got everything exactly as it was , no additionnal registry ,wsl.conf and etc.. my environements are all working as they should , no errors , just how an import / export should be transparent. i dunno what they did over at m$ with their import/export function that cant handle exporting properly, enjoy

2019211753 commented 1 year ago

I still have this error, thanks for the feedback all. I get this error when running

PS C:\Users\Ryan> wsl -d Ubuntu-20.04 -u root
There is no distribution with the supplied name.
Error code: Wsl/Service/WSL_E_DISTRO_NOT_FOUND

but in my wsl ubuntu shell I get

# root at rave in ~ [13:39:26]
→ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.5 LTS
Release:        20.04
Codename:       focal

the wsl.conf shows

[user]
default=rave

it looks like this user doesn't exist after the wsl update for some reason

# root at rave in ~ [13:43:51]
→ cut -d: -f1 /etc/passwd
root
daemon
bin
sys
sync
games
man
lp
mail
news
uucp
proxy
www-data
backup
list
irc
gnats
nobody
systemd-network
systemd-resolve
systemd-timesync
messagebus
syslog
_apt
tss
uuidd
tcpdump
sshd
landscape
pollinate
dnsmasq

but when I set my wsl.conf to the root user, I still get the error message

<3>WSL (23176) ERROR: CreateProcessEntryCommon:355: getpwnam(rave) failed 0

Did you do a wsl --shutdown on the Windows Command Prompt after you set the default user to root?

thank you! Your solution also works for me! -3-

tilkinsc commented 10 months ago

I am using arch and I (assume $username is defined from here on) useradd -m "$username" -s /bin/bash and the user doesn't exist in the users command. The home directory is created and I can su - $username even after a wsl --shutdown. I attempted to add the user to /etc/wsl.conf. The only difference in this situation is I set a password for the user account. The user appears as $username:x:1000:1000::/home/$username:/bin/bash

The problem for the users command is the user wasn't ever logged in. The /etc/wsl.conf issue is related to an incorrect username. Seems like passwords are ignored entirely here which is unfortunate. I opted to shutdown now my machine instead of exit then force a shutdown just to be safe. It logs me in normally. Watch out for case sensitivity in the username.

MaVeron30 commented 1 month ago

I had a similar problem, I wanted to set the default user to root, but in [user] section default = root it didn't help, because it didn't find the root user in the /mnt/c/Users/User section. I solved this problem when I wrote to the ./etc/wsl.conf file in the [automount] section root = .

lammabing commented 6 days ago

cd /etc sudo nano wsl.conf

[user] default=username #change to your username then save

Exit from bash into PowerShell, then the following command: wsl --terminate # (most likely is Ubuntu

Restart wsl