Ubuntu – Cant install or remove anything on 18.04 cause of DPKG error

18.04aptdpkgpackage-management

Last time I was able to install is install adobe using snap now I cant install anything and having multiple errors; when I run sudo dpkg –configure -a , sudo apt-get -f install I get below

martin@martin:~$ sudo dpkg --configure -a
Setting up php-pear (1:1.10.8+submodules+notgz-1+ubuntu16.04.1+deb.sury.org+1) ...
dpkg-maintscript-helper: error: dpkg: error: unknown option --validate-version

Type dpkg --help for help about installing and deinstalling packages [*];
Use 'apt' or 'aptitude' for user-friendly package management;
Type dpkg -Dhelp for a list of dpkg debug flag values;
Type dpkg --force-help for a list of forcing options;
Type dpkg-deb --help for help about manipulating *.deb files;

Options marked [*] produce a lot of output - pipe it through 'less' or 'more' !
dpkg: error processing package php-pear (--configure):
 subprocess installed post-installation script returned error exit status 1
Setting up mysql-common (5.8+1.0.4) ...
dpkg-maintscript-helper: error: dpkg: error: unknown option --validate-version

Type dpkg --help for help about installing and deinstalling packages [*];
Use 'apt' or 'aptitude' for user-friendly package management;
Type dpkg -Dhelp for a list of dpkg debug flag values;
Type dpkg --force-help for a list of forcing options;
Type dpkg-deb --help for help about manipulating *.deb files;

Options marked [*] produce a lot of output - pipe it through 'less' or 'more' !
dpkg: error processing package mysql-common (--configure):
 subprocess installed post-installation script returned error exit status 1
Setting up mysql-utilities (1.6.4-1) ...
dpkg-maintscript-helper: error: dpkg: error: unknown option --validate-version

Type dpkg --help for help about installing and deinstalling packages [*];
Use 'apt' or 'aptitude' for user-friendly package management;
Type dpkg -Dhelp for a list of dpkg debug flag values;
Type dpkg --force-help for a list of forcing options;
Type dpkg-deb --help for help about manipulating *.deb files;

Options marked [*] produce a lot of output - pipe it through 'less' or 'more' !
dpkg: error processing package mysql-utilities (--configure):
 subprocess installed post-installation script returned error exit status 1
Setting up apache2 (2.4.29-1ubuntu4.13) ...
dpkg-maintscript-helper: error: dpkg: error: unknown option --validate-version

Type dpkg --help for help about installing and deinstalling packages [*];
Use 'apt' or 'aptitude' for user-friendly package management;
Type dpkg -Dhelp for a list of dpkg debug flag values;
Type dpkg --force-help for a list of forcing options;
Type dpkg-deb --help for help about manipulating *.deb files;

Options marked [*] produce a lot of output - pipe it through 'less' or 'more' !
dpkg: error processing package apache2 (--configure):
 subprocess installed post-installation script returned error exit status 1
Setting up git (1:2.17.1-1ubuntu0.7) ...
dpkg-maintscript-helper: error: dpkg: error: unknown option --validate-version

Type dpkg --help for help about installing and deinstalling packages [*];
Use 'apt' or 'aptitude' for user-friendly package management;
Type dpkg -Dhelp for a list of dpkg debug flag values;
Type dpkg --force-help for a list of forcing options;
Type dpkg-deb --help for help about manipulating *.deb files;

Options marked [*] produce a lot of output - pipe it through 'less' or 'more' !
dpkg: error processing package git (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 php-pear
 mysql-common
 mysql-utilities
 apache2
 git
martin@martin:~$ 

This is a copy of my /var/lib/dpkg/status

  GNU nano 2.9.3                                                  /var/lib/dpkg/status                                                            

Description: API library for scanners -- utilities
 SANE stands for "Scanner Access Now Easy" and is an application
 programming interface (API) that provides standardized access to any
 raster image scanner hardware (flatbed scanner, hand-held scanner,
 video- and still-cameras, frame-grabbers, etc.). The SANE standard is
 free and its discussion and development are open to everybody. The
 current source code is written to support several operating systems,
 including GNU/Linux, OS/2, Win32 and various Unices and is available
 under the GNU General Public License (commercial applications and
 backends are welcome, too, however).
 .
 This package includes the command line frontend scanimage, the saned
 server and the sane-find-scanner utility, along with their documentation.
Homepage: http://www.sane-project.org
Original-Maintainer: Jörg Frings-Fürst <debian@jff-webhosting.net>

Package: python-yaml
Status: install ok installed
Priority: optional
Section: python
Installed-Size: 468
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: amd64
Source: pyyaml
Version: 3.12-1build2
Depends: python (<< 2.8), python (>= 2.7~), python:any (<< 2.8), python:any (>= 2.7.5-5~), libc6 (>= 2.14), libyaml-0-2
Description: YAML parser and emitter for Python
 Python-yaml is a complete YAML 1.1 parser and emitter for Python.  It can parse
 all examples from the specification. The parsing algorithm is simple enough to
 be a reference for YAML parser implementors. A simple extension API is also
 provided.  The package is built using libyaml for improved speed.

^G Get Help     ^O Write Out    ^W Where Is     ^K Cut Text     ^J Justify      ^C Cur Pos      M-U Undo        M-A Mark Text   M-] To Bracket
^X Exit         ^R Read File    ^\ Replace      ^U Uncut Text   ^T To Spell     ^_ Go To Line   M-E Redo        M-6 Copy Text   M-W WhereIs Next

When I try removing php-pear

martin@martin:~$ sudo apt-get remove php-pear
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  php-cli php-xml php7.2-cli php7.2-common php7.2-json php7.2-opcache php7.2-readline php7.2-xml
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  php-pear
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
5 not fully installed or removed.
After this operation, 2,117 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 173197 files and directories currently installed.)
Removing php-pear (1:1.10.8+submodules+notgz-1+ubuntu16.04.1+deb.sury.org+1) ...
dpkg-maintscript-helper: error: dpkg: error: unknown option --validate-version

Type dpkg --help for help about installing and deinstalling packages [*];
Use 'apt' or 'aptitude' for user-friendly package management;
Type dpkg -Dhelp for a list of dpkg debug flag values;
Type dpkg --force-help for a list of forcing options;
Type dpkg-deb --help for help about manipulating *.deb files;

Options marked [*] produce a lot of output - pipe it through 'less' or 'more' !
dpkg: error processing package php-pear (--remove):
 subprocess installed pre-removal script returned error exit status 1
dpkg-maintscript-helper: error: dpkg: error: unknown option --validate-version

Type dpkg --help for help about installing and deinstalling packages [*];
Use 'apt' or 'aptitude' for user-friendly package management;
Type dpkg -Dhelp for a list of dpkg debug flag values;
Type dpkg --force-help for a list of forcing options;
Type dpkg-deb --help for help about manipulating *.deb files;

Options marked [*] produce a lot of output - pipe it through 'less' or 'more' !
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 php-pear
E: Sub-process /usr/bin/dpkg returned an error code (1)
martin@martin:~$ 

EDIT:

martin@martin:~$ python -V
Python 2.7.17
martin@martin:~$ which python
/usr/bin/python
martin@martin:~$ 

dpkg:

martin@martin:~$ dpkg --version
Debian `dpkg' package management program version 1.17.5 (amd64).
This is free software; see the GNU General Public License version 2 or
later for copying conditions. There is NO warranty.
martin@martin:~$ 

Best Answer

  • Your dpkg has wrong version somehow, Ubuntu 18.04 currently has version 1.19.0.5. You need to reinstall dpkg:

    Try this:

    sudo -i
    mkdir /tmp/dpkg
    cd /tmp/dpkg
    wget http://launchpadlibrarian.net/366329727/dpkg_1.19.0.5ubuntu2_amd64.deb
    ar x dpkg*.deb data.tar.xz
    tar xvf data.tar.xz ./usr/bin/dpkg
    cp ./usr/bin/dpkg /usr/bin/
    apt-get update
    apt-get install --reinstall dpkg
    

    From can't install software--can I fix missing dpkg?

  • Related Question