apt upgrade or aptautoremove failing with E: Sub-process /usr/bin/dpkg returned an error code (1)

Asked by Rodivaldo Marcelo Raimundo on 2020-06-22

After run commands "sudo apt upgrade" and "sudo apt autoremove" the following is happening:

$ sudo apt upgrade
Upgrading packages that are needed to be...
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up brave-browser (1.10.93) ...
update-alternatives: error: alternative link /usr/bin/x-www-browser is already managed by gnome-www-browser
dpkg: error processing package brave-browser (--configure):
 installed brave-browser package post-installation script subprocess returned error exit status 2
Setting up google-chrome-stable (83.0.4103.106-1) ...
update-alternatives: error: alternative link /usr/bin/x-www-browser is already managed by gnome-www-browser
dpkg: error processing package google-chrome-stable (--configure):
 installed google-chrome-stable package post-installation script subprocess returned error exit status 2
Errors were encountered while processing:
 brave-browser
 google-chrome-stable
E: Sub-process /usr/bin/dpkg returned an error code (1)
$
$ sudo apt autoremove -y
Removing unnecessary packages...
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up brave-browser (1.10.93) ...
update-alternatives: error: alternative link /usr/bin/x-www-browser is already managed by gnome-www-browser
dpkg: error processing package brave-browser (--configure):
 installed brave-browser package post-installation script subprocess returned error exit status 2
Setting up google-chrome-stable (83.0.4103.106-1) ...
update-alternatives: error: alternative link /usr/bin/x-www-browser is already managed by gnome-www-browser
dpkg: error processing package google-chrome-stable (--configure):
 installed google-chrome-stable package post-installation script subprocess returned error exit status 2
Errors were encountered while processing:
 brave-browser
 google-chrome-stable
E: Sub-process /usr/bin/dpkg returned an error code (1)

Did someone experienced this kind of failure? If yes, any way to fix it?

Thanks in advance very much.

My best regards.

Rod.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Rodivaldo Marcelo Raimundo
Solved:
2020-06-27
Last query:
2020-06-27
Last reply:
2020-06-22

This question was reopened

What is the output of:

lsb_release -a; uname -a; apt-cache policy brave-browser

Thanks

Manfred Hampl (m-hampl) said : #2

The error message indicates a conflict between different packages.
Apparently you can install only one package from the list
 brave-browser
 google-chrome-stable
 gnome-www-browser
a the same time.

To bring your package management system back into a sane status I recommend executing the command

sudo dpkg --purge brave-browser google-chrome-stable

Good morning @actionparsnip.

This is the commands output you asked for:

# lsb_release -a; uname -a; apt-cache policy brave-browser
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.4 LTS
Release: 18.04
Codename: bionic
Linux ussdefiant 5.3.0-59-generic #53~18.04.1-Ubuntu SMP Thu Jun 4 14:58:26 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
brave-browser:
  Installed: 1.10.93
  Candidate: 1.10.93
  Version table:
 *** 1.10.93 500
        500 https://brave-browser-apt-release.s3.brave.com stable/main amd64 Packages
        100 /var/lib/dpkg/status
     1.10.90 500
        500 https://brave-browser-apt-release.s3.brave.com stable/main amd64 Packages
     1.9.80 500
        500 https://brave-browser-apt-release.s3.brave.com stable/main amd64 Packages
     1.9.76 500
        500 https://brave-browser-apt-release.s3.brave.com stable/main amd64 Packages
     1.9.72 500
        500 https://brave-browser-apt-release.s3.brave.com stable/main amd64 Packages
     1.8.96 500
        500 https://brave-browser-apt-release.s3.brave.com stable/main amd64 Packages
     1.8.95 500
        500 https://brave-browser-apt-release.s3.brave.com stable/main amd64 Packages
     1.8.90 500
        500 https://brave-browser-apt-release.s3.brave.com stable/main amd64 Packages
     1.8.86 500
        500 https://brave-browser-apt-release.s3.brave.com stable/main amd64 Packages
     1.7.98 500
        500 https://brave-browser-apt-release.s3.brave.com stable/main amd64 Packages
#

As stated. I suggest you remove either Brave or Chrome and use the other

Kai Kasurinen (kai-kasurinen) said : #5

What is the output of:

update-alternatives --display x-www-browser
update-alternatives --display gnome-www-browser

Hello Kai Kasurinen.

This is the output you asked for:

# update-alternatives --display x-www-browser
update-alternatives: error: no alternatives for x-www-browser
# update-alternatives --display gnome-www-browser
gnome-www-browser - auto mode
  link best version is /usr/bin/firefox
  link currently points to /usr/bin/firefox
  link gnome-www-browser is /usr/bin/x-www-browser
/usr/bin/firefox - priority 40
#

Kai Kasurinen (kai-kasurinen) said : #7

somehow your gnome-www-browser alternative is broken/corrupted:
"link gnome-www-browser is /usr/bin/x-www-browser"
should be:
"link gnome-www-browser is /usr/bin/gnome-www-browser"

it may be fixable with update-alternative command or editing file /var/lib/dpkg/alternatives/gnome-www-browser by hand (second line on that file).

Hello Hello Kai Kasurinen.

I do apologize for the delay to respond.

I have replaced the line you pointed in the file /var/lib/dpkg/alternatives/gnome-www-browser, and all is now working fine.

I really appreciate your tip about that. Now all the erros have been suppressed.

Thanks very much one more time.

Rod.