How to resolve "unknown user 'elasticsearch' in statoverride file" error?

I have been trying to install Elastic Search, I have downloaded the the elasticsearch-2.3.4.deb file. When I try to use the command:

sudo dpkg -i elasticsearch-1.7.2.deb

It outputs this error:

dpkg: unrecoverable fatal error, aborting: unknown user 'elasticsearch' in statoverride file

How can I fix this?


Solution 1:

In my case, following these steps worked:

  • Begin by completely uninstalling any Elasticsearch instances on your machine:

    apt remove --purge elasticsearch
    apt autoremove
    
  • Then, open the /var/lib/dpkg/statoverride file in your editor and remove lines mentioning the elasticsearch user.

It's not an ideal solution because it involves manually editing files which are normally modified only by dpkg itself, but running dpkg-reconfigure and apt --reinstall install didn't work for me; this was a last resort.

Solution 2:

open the file

/var/lib/dpkg/statoverride

you should see something like:

root elasticsearch 755 /var/log/elasticsearch

or

root elasticsearch 755 /var/lib/elasticsearch

if so, run dpkg-statoverride --remove:

dpkg-statoverride --remove /var/log/elasticsearch
dpkg-statoverride --remove /var/lib/elasticsearch

Solution 3:

I just need

sudo dpkg-statoverride --remove /var/lib/elasticsearch
sudo dpkg-statoverride --remove /var/log/elasticsearch

Solution 4:

The issue for me was that I renamed the default user to fall in line with my naming scheme on my server.

I resolved this issue by editing the

/var/lib/dpkg/statoverride

file and replacing the old name with the new. No need to uninstall the application.