User disappeared during update

 23.04.2020 -   -  ~2 Minutes

When trying to install a package it can happen that it fails because the user to be created ‘disappeared’.

User disappeared during update

This happened when I tried to install openntpd.

root@freebsd:~ # pkg install openntpd
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
Checking integrity... done (0 conflicting)
The following 1 package(s) will be affected (of 0 checked): 

New packages to be INSTALLED:
     openntpd: 6.2p3_4,2                                                               

Number of packages to be installed: 1

The process will require 1 MiB more space.

Proceed with this action? [y/N]: y

===> Creating groups.

===> Creating users
Creating user '_ntp' with uid '233'.
pw: user '_ntp' disappeared during update
pkg: PRE-INSTALL script failed

Solution

First call vipw

root@freebsd:~ # vipw

Do not change anything. Just type:

:wq

And press <Enter>. This will sync your user database.

vipw: password list updated

Now you can try again to install the package.

root@freebsd:~ # pkg install openntpd
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
Checking integrity... done (0 conflicting)
The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
     openntpd: 6.2p3_4,2

Number of packages to be installed: 1

The process will require 1 MiB more space.

Proceed with this action? [y/N]: y
[1/1] Installing openntpd-6.2p3_4,2...
===> Creating groups.                        
Using existing group '_ntp'.
===> Creating users                          
Using existing user '_ntp'.
[1/1] Extracting openntpd-6.2p3_4,2: 100%

Finally the package is successfully installed.