Solved Error adding new user - pw: user 'anne' disappeared during update

Hei,

As root, I'm trying to add a new user with adduser but it returnes a strange error when I confirm.
Only the group 'anne' gets created, but nothing more. I checked pw(8) for something helpful as it seems like it's pw creating the error and checked /var/log/messages and /var/log/auth.log but nothing strange there.
Code:
Username   : anne
Password   : *****
Full Name  : Anne
Uid        : 2001
Class      :
Groups     : anne
Home       : /home/anne
Home Mode  :
Shell      : /bin/sh
Locked     : no
OK? (yes/no): yes
pw: user 'anne' disappeared during update
adduser: ERROR: There was an error adding user (anne).
Add another user? (yes/no): no
Goodbye!

Anyone who could help? Thanks!
Matthias
 

SirDice

Administrator
Staff member
Administrator
Moderator
Your databases are out of sync. Not sure how this happens but I get it from time to time too. Run /usr/sbin/pwd_mkdb -p /etc/master.passwd. Running vipw(8) and save-and-quit (without actually making any changes) also fixes it (easier to remember).
 
Your databases are out of sync. Not sure how this happens but I get it from time to time too. Run /usr/sbin/pwd_mkdb -p /etc/master.passwd. Running vipw(8) and save-and-quit (without actually making any changes) also fixes it (easier to remember).
Thank to you SirDice. I'm very glad with all of you in this list. I've been two times with a doubt and found a brilliant answer: and, of course, problem solution.
 
This just worked for me while upgrading packages on FreeBSD-12.2-RELEASE. Thanks, SirDice. Didn't try vipw, the pwd_mkdb fixed it.
 
This seems to happen consistently on a fresh install of FreeBSD 12.2 and installing MySQL 5.7 from ports - so make install is running, and at the end:
Code:
===>   Registering installation for mysql57-server-5.7.32
Installing mysql57-server-5.7.32...
===> Creating groups.
Creating group 'mysql' with gid '88'.
===> Creating users
Creating user 'mysql' with uid '88'.
pw: user 'mysql' disappeared during update
===> Creating homedir(s)
install: unknown user mysql
pkg-static: PRE-INSTALL script failed
This seems to get you back on track (well, worked for me):
Code:
# /usr/sbin/pwd_mkdb -p /etc/master.passwd
# make reinstall
 
I too encountered this issue just now, installing mariadb from the pkg. The fix above worked for me as well.
 
Just got bit by this upgrading to 12.2. The fix above didn't work, all my users were still gone. The following worked
/usr/sbin/pwd_mkdb -p /var/backup/master.passwd.bak. I had to restore /etc/group from /var/backup as well. I made copies of everything first.
 
Just saw it here on 12.2-p10:

Code:
root@nj2 ~]# freebsd-version -u
12.2-RELEASE-p10
[root@nj2 ~]# freebsd-version -k
12.2-RELEASE-p7
[root@nj2 ~]#
[root@nj2 ~]# pkg install php74-pecl-imagick-3.5.1
...
Proceed with this action? [y/N]: y
...
[1/28] Installing dbus-1.12.20_5...
===> Creating groups.
Using existing group 'messagebus'.
===> Creating users
Creating user 'messagebus' with uid '556'.
pw: user 'messagebus' disappeared during update
pkg: PRE-INSTALL script failed
[root@nj2 ~]#
[root@nj2 ~]# /usr/sbin/pwd_mkdb -p /etc/master.passwd
[root@nj2 ~]#
[root@nj2 ~]# pkg install php74-pecl-imagick-3.5.1
...
[10/28] Installing avahi-app-0.8...
===> Creating groups.
Creating group 'avahi' with gid '558'.
===> Creating users
Creating user 'avahi' with uid '558'.
pw: group `558' does not exist
pkg: PRE-INSTALL script failed
[root@nj2 ~]#
[root@nj2 ~]# /usr/sbin/pwd_mkdb -p /etc/master.passwd
[root@nj2 ~]# pkg install php74-pecl-imagick-3.5.1
Proceed with this action? [y/N]: y
...
[1/19] Installing avahi-app-0.8...
===> Creating groups.
Using existing group 'avahi'.
===> Creating users
Creating user 'avahi' with uid '558'.
pw: user 'avahi' disappeared during update
pkg: PRE-INSTALL script failed
[root@nj2 ~]# /usr/sbin/pwd_mkdb -p /etc/master.passwd
[root@nj2 ~]# pkg install php74-pecl-imagick-3.5.1
...
[4/19] Installing cups-2.3.3op2...
===> Creating groups.
Creating group 'cups' with gid '193'.
===> Creating users
Creating user 'cups' with uid '193'.
pw: group `193' does not exist
pkg: PRE-INSTALL script failed
[root@nj2 ~]#
[root@nj2 ~]# /usr/sbin/pwd_mkdb -p /etc/master.passwd
[root@nj2 ~]# pkg install php74-pecl-imagick-3.5.1
...
Proceed with this action? [y/N]: y
[1/16] Installing cups-2.3.3op2...
===> Creating groups.
Creating group 'cups' with gid '193'.
===> Creating users
Creating user 'cups' with uid '193'.
pw: group `193' does not exist
pkg: PRE-INSTALL script failed
[root@nj2 ~]# /usr/sbin/pwd_mkdb -p /etc/master.passwd

[root@nj2 ~]# pkg install php74-pecl-imagick-3.5.1

Not really any rhyme or reason here. The "fix" of manually regenerating the password db maybe does something? Hard to tell.
 
Top