8

I'm using PureOS, which is basically Debian with some small tweaks. I tried installing firefox on it, but ended with a complete mess. If I now try to do a basic upgrade, I get this:

$ sudo apt update && sudo apt upgrade
Ign:1 http://deb.debian.org/debian stretch InRelease
Get:2 http://deb.debian.org/debian stretch-updates InRelease [91.0 kB]              
Get:3 http://deb.opera.com/opera stable InRelease [2592 B]                          
Get:4 http://security.debian.org stretch/updates InRelease [63.0 kB]                
Hit:5 http://deb.debian.org/debian stretch Release                                  
Get:6 https://repo.skype.com/deb stable InRelease [4486 B]                          
Get:7 http://deb.opera.com/opera stable/non-free amd64 Packages [1835 B]            
Get:8 http://packages.microsoft.com/repos/vscode stable InRelease [2801 B]          
Get:9 http://repository.spotify.com stable InRelease [3302 B]                       
Get:10 http://repo.puri.sm/pureos green InRelease [9427 B]                          
Get:12 http://security.debian.org stretch/updates/main Sources [110 kB]             
Get:13 http://security.debian.org stretch/updates/contrib Sources [1384 B]          
Get:14 http://security.debian.org stretch/updates/main amd64 Packages [271 kB]      
Get:15 https://repo.skype.com/deb stable/main amd64 Packages [2251 B]               
Get:16 http://security.debian.org stretch/updates/main Translation-en [120 kB]      
Get:17 http://security.debian.org stretch/updates/contrib amd64 Packages [1776 B]   
Get:18 http://security.debian.org stretch/updates/contrib Translation-en [1759 B]   
Get:19 https://download.sublimetext.com apt/stable/ InRelease [2562 B]              
Get:20 http://packages.microsoft.com/repos/vscode stable/main amd64 Packages [39.6 kB]
Ign:21 https://mega.nz/linux/MEGAsync/Debian_9.0 ./ InRelease                       
Get:22 http://repo.puri.sm/pureos green/main amd64 Packages [6286 kB]               
Get:23 https://mega.nz/linux/MEGAsync/Debian_9.0 ./ Release [976 B]                 
Get:26 http://repo.puri.sm/pureos green/main Translation-en [5583 kB]               
Hit:24 https://packagecloud.io/slacktechnologies/slack/debian jessie InRelease      
Get:27 http://repo.puri.sm/pureos green/main amd64 DEP-11 Metadata [2202 kB]        
Get:28 http://repo.puri.sm/pureos green/main DEP-11 64x64 Icons [6768 kB]
Fetched 21.6 MB in 4s (5487 kB/s)                                     
Reading package lists... Done
Building dependency tree       
Reading state information... Done
59 packages can be upgraded. Run 'apt list --upgradable' to see them.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 iceweasel : Depends: firefox-esr but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

So I tried to suggestion:

$ sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  firefox-esr
Suggested packages:
  fonts-stix | otf-stix fonts-lmodern mozplugger
The following NEW packages will be installed:
  firefox-esr
0 upgraded, 1 newly installed, 0 to remove and 59 not upgraded.
2 not fully installed or removed.
Need to get 0 B/46.5 MB of archives.
After this operation, 114 MB of additional disk space will be used.
Do you want to continue? [Y/n] 
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = "en_US",
    LC_ALL = (unset),
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
(Reading database ... 227765 files and directories currently installed.)
Preparing to unpack .../firefox-esr_52.6.0esr-1~deb9u1_amd64.deb ...
dpkg-divert: error: 'diversion of /usr/bin/firefox to /usr/bin/firefox.real by firefox-esr' clashes with 'diversion of /usr/bin/firefox to /usr/bin/firefox.real by purebrowser'
dpkg: error processing archive /var/cache/apt/archives/firefox-esr_52.6.0esr-1~deb9u1_amd64.deb (--unpack):
 new firefox-esr package pre-installation script subprocess returned error exit status 2
Errors were encountered while processing:
 /var/cache/apt/archives/firefox-esr_52.6.0esr-1~deb9u1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

And now I'm kinda stuck.

Does anybody know what I can do to clean this mess? All tips are welcome!

[EDIT]

I've tried to remove firefox in many ways:

$ sudo apt -y remove firefox
[sudo] password for hielke: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package 'firefox' is not installed, so not removed
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 iceweasel : Depends: firefox-esr but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

I've also tried the following variations, but all gave similar results:

sudo apt remove firefox
sudo apt purge firefox
sudo apt remove firefox-esr
sudo apt purge firefox-esr
sudo apt remove iceweasel
sudo apt purge iceweasel
sudo apt remove purebrowser
sudo apt purge purebrowser

[EDIT 2]

Following the answer by @alan I tried removing the diversion:

$ sudo dpkg-divert --remove /usr/bin/firefox
Removing 'diversion of /usr/bin/firefox to /usr/bin/firefox.real by purebrowser'

After that I did an update and then an upgrade:

$ sudo apt update
Hit:1 http://security.debian.org stretch/updates InRelease
Hit:2 http://repo.puri.sm/pureos green InRelease                                                                                         
Hit:3 http://deb.opera.com/opera stable InRelease                                                                                        
Ign:4 http://deb.debian.org/debian stretch InRelease                                                                                     
Hit:5 http://packages.microsoft.com/repos/vscode stable InRelease                                                                        
Hit:6 http://deb.debian.org/debian stretch-updates InRelease                                                                             
Hit:7 http://deb.debian.org/debian stretch Release                                                                                       
Hit:8 https://repo.skype.com/deb stable InRelease                                                                                        
Ign:9 https://mega.nz/linux/MEGAsync/Debian_9.0 ./ InRelease                                                                             
Hit:10 http://repository.spotify.com stable InRelease                                                                                    
Hit:11 https://download.sublimetext.com apt/stable/ InRelease                                                                            
Get:12 https://mega.nz/linux/MEGAsync/Debian_9.0 ./ Release [976 B]                                                                     
Hit:14 https://packagecloud.io/slacktechnologies/slack/debian jessie InRelease                          
Fetched 976 B in 3s (385 B/s)                                                                   
Reading package lists... Done
Building dependency tree       
Reading state information... Done
135 packages can be upgraded. Run 'apt list --upgradable' to see     them.
$
$
$
$ sudo apt upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 iceweasel : Depends: firefox-esr but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

Unfortunately the same result as you can see. I tried apt --fix-broken install just to be sure, but that gave the same result as before.

So I used the command to find other diversions (although I'm not 100% sure what diversions are exactly):

& sudo dpkg-divert --list | grep firefox
diversion of /usr/share/applications/firefox-esr.desktop to /usr/share/applications/firefox-esr.desktop.diverted by xul-ext-iceweasel-branding

So I just filled in what I thought was right:

$ sudo dpkg-divert --remove /usr/share/applications/firefox-esr.desktop
Removing 'diversion of /usr/share/applications/firefox-esr.desktop to /usr/share/applications/firefox-esr.desktop.diverted by xul-ext-iceweasel-branding'

but again I get the same:

$ sudo apt upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 iceweasel : Depends: firefox-esr but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

and another try to fix it:

$ sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  firefox-esr
Suggested packages:
  fonts-stix | otf-stix fonts-lmodern mozplugger
The following NEW packages will be installed:
  firefox-esr
0 upgraded, 1 newly installed, 0 to remove and 135 not upgraded.
2 not fully installed or removed.
Need to get 0 B/46.5 MB of archives.
After this operation, 114 MB of additional disk space will be used.
Do you want to continue? [Y/n] 
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = "en_US",
    LC_ALL = (unset),
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
(Reading database ... 227763 files and directories currently installed.)
Preparing to unpack .../firefox-esr_52.6.0esr-1~deb9u1_amd64.deb ...
Adding 'diversion of /usr/bin/firefox to /usr/bin/firefox.real by firefox-esr'
Unpacking firefox-esr (52.6.0esr-1~deb9u1) ...
dpkg: error processing archive /var/cache/apt/archives/firefox-esr_52.6.0esr-1~deb9u1_amd64.deb (--unpack):
 trying to overwrite '/usr/share/applications/firefox-esr.desktop', which is also in package xul-ext-iceweasel-branding 0.4.0
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/firefox-esr_52.6.0esr-1~deb9u1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Any more tips?

[EDIT 3]

Following the tips from @harrymc I tried running this:

$ sudo apt-get install iceweasel
[sudo] password for hielke: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
iceweasel is already the newest version (52.6.0esr-1~deb9u1).
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 iceweasel : Depends: firefox-esr but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

As you can see that didn't do the trick. So here's the output apt-cache policy firefox-esr:

$ apt-cache policy firefox-esr
firefox-esr:
  Installed: (none)
  Candidate: 52.6.0esr-1~deb9u1
  Version table:
     52.6.0esr-1~deb9u1 500
        500 http://security.debian.org stretch/updates/main amd64 Packages
     52.5.0esr-1~deb9u1 500
        500 http://deb.debian.org/debian stretch/main amd64 Packages

Just for info, here are the contents of my /etc/apt/sources.list:

deb http://repo.puri.sm/pureos/ green main
deb http://deb.opera.com/opera/ stable non-free
# deb-src http://deb.opera.com/opera/ stable non-free
# deb http://security.debian.org/debian-security stretch/updates main
# deb http://httpredir.debian.org/debian/ stretch main contrib non-free

deb http://deb.debian.org/debian stretch main contrib non-free
deb-src http://deb.debian.org/debian stretch main contrib non-free

deb http://deb.debian.org/debian stretch-updates main contrib non-free
deb-src http://deb.debian.org/debian stretch-updates main contrib non-free

deb http://security.debian.org/ stretch/updates main contrib non-free
deb-src http://security.debian.org/ stretch/updates main contrib non-free

Does this tell you anything?

kramer65
  • 1,394
  • 4
  • 21
  • 43
  • Have you tried removing the broken Firefox installation? `sudo apt -y remove ` – Prav Feb 09 '18 at 22:56
  • @PraveenP - yes I did. I added that to the question. Any other ideas? – kramer65 Feb 11 '18 at 17:05
  • See [this answer](https://askubuntu.com/a/282746). – harrymc Feb 11 '18 at 21:34
  • Following EDIT 2: Try to run this command : `sudo apt-get install iceweasel`. If this doesn't help, please provide the output of `apt-cache policy firefox-esr`. And which repository are you using with apt? – harrymc Feb 12 '18 at 20:30
  • @harrymc - Thanks for the tip. Unfortunately that doesn't do it yet. I've added the results to the question under [EDIT 3]. Does that tell you anything? – kramer65 Feb 12 '18 at 22:10
  • Following EDIT 3: Iceweasel might be the problem, as it is a rebranded version of Firefox, but discontinued now. Try `apt-get remove iceweasel`. – harrymc Feb 13 '18 at 07:30
  • @harrymc - I tried variations of that already (and again now) but that doesn't make any difference. – kramer65 Feb 13 '18 at 08:52
  • @kramer65 When you get a chance, can you hop into [chat](https://chat.stackexchange.com/rooms/118/root-access)? I'd like to try some more interactive troubleshooting. – Bob Feb 13 '18 at 12:55
  • Give it a look if it is the case to clean _manually_ the temporary download/cache/packages... and to start to install firefox again. [Self-citation](https://askubuntu.com/a/498949/196535). Note that `apt` and `apt-get` may work in a different way and that `apt-get` has two different options `-m` and `-f`, sadly [another self-citation](https://askubuntu.com/a/462751/196535) `:-)`. – Hastur Feb 15 '18 at 12:49

4 Answers4

5

Firefox is trying to create a diversion, when a diversion with that name already exists.

You need to remove the existing diversion first.

This is the error line:

dpkg-divert: error: 'diversion of /usr/bin/firefox to /usr/bin/firefox.real by firefox-esr' clashes with 'diversion of /usr/bin/firefox to /usr/bin/firefox.real by purebrowser'

From this solution:

sudo dpkg-divert --remove /usr/bin/firefox

Note: if the diversion is not caused by /usr/bin/firefox, you may need to identify the diversion with either sudo dpkg-divert --list | grep firefox or sudo dpkg-divert --list | grep purebrowser On a side note, if you don't like the locale error message thrown by Perl, you can get rid of it by exporting your locale, as shown here:

export LC_CTYPE=en_US.UTF-8
export LC_ALL=en_US.UTF-8

If all else fails, open up the package record and remove iceweasel by hand:

sudo -i gedit /var/lib/dpkg/status

(you'll probably see a block that starts something like Package: Iceweasel Status: Install broken). See this similar issue: Unable to fix broken packages with sudo apt-get install -f

harrymc
  • 455,459
  • 31
  • 526
  • 924
Alan
  • 514
  • 3
  • 8
  • Hi Alan. Thanks for your suggestions. I tried them but I didn't get to a solution. I described it in the question under `[EDIT 2]`. Do you have any other ideas? – kramer65 Feb 12 '18 at 16:47
  • A diversion is an instruction to install a file etc. from a package with a different name than it would normally be installed (e.g. firefox -> firefox.desktop). To remove the diversion you need to remove the source, not the result. Try: `sudo dpkg-divert --remove /usr/share/applications/firefox-esr/xul-ext-iceweasel-branding` – Alan Feb 13 '18 at 00:11
  • I tried your suggestion, but then I get `No diversion 'any diversion of /usr/share/applications/firefox-esr/xul-ext-iceweasel-branding', none removed.` – kramer65 Feb 13 '18 at 07:37
  • I know you've tried removing the browsers, but have you tried removing the branding package? It's long shot but removing them in order (apt purge) and reinstalling just the appropriate package. Looks like the order is xul-ext-iceweasel-branding->iceweasel->firefox. You shouldn't need iceweasel or firefox as PureOS provides PureBrowser. – Alan Feb 13 '18 at 21:11
  • 1
    If all else fails, open up the package record and remove iceweasel by hand: **sudo -i gedit /var/lib/dpkg/status** (you'll probably see a block that starts something like Package: Iceweasel Status: Install broken). See this similar issue: https://askubuntu.com/questions/146150/unable-to-fix-broken-packages-with-sudo-apt-get-install-f – Alan Feb 13 '18 at 21:19
  • Your last comment helped me out. If you add it to your answer I can accept your answer. – kramer65 Feb 17 '18 at 09:42
  • @kramer65 - done. – Alan Feb 18 '18 at 18:53
2

Use this: sudo dpkg -i --force-all /var/cache/apt/archives/firefox-esr_52.6.0esr-1~deb9u1_amd64.deb and you will force-install firefox-esr. 99.9% it'll fix your problem. Then follow it up with sudo dpkg --configure -a and you'll most probaly be in the clear.

As a general rule, when mixing stuff in installations you'll find a package that needs to overwrite a file from another package. Using dpkg with the --force-all option in these cases lets you play God, but it also overrules all those nice security checks built in in Debian's package management system. But after all, that's one of the burdens of being the root user.

gmelis
  • 677
  • 3
  • 7
0

When you look at the repos the Debian includes the 'Iceweasel' package while the PureOS repo contains the firefox-esr package. Based on the error messages they are conflicting.

This might remove your Firefox profile but I would try:

sudo apt purge firefox firefox-esr iceweasel purebrowser
sudo apt install firefox-esr

That should install the firefox package from the PureOS repo.

Iceweasel was a rebrand of Firefox done by Debian but they are reverting their changes. In Debian stretch it's still called Iceweasel but it simply installs a patched firefox-esr, in the next Debian version it should simply be called firefox-esr.

Is it possible you added those debian repos yourself? That's never a good idea to mix distro repositories. Comment those lines out then:

apt clean && apt update

Then try again to purge & install.

HoD
  • 3,277
  • 15
  • 19
  • 1
    Thanks, but as you can read in the question I've tried removing all related browsers (firefox, firefox-esr, iceweasel and purebrowser) using both `apt remove` and `apt purge`. But that gives me some output, ending in the error `E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).` Any ideas how I can overcome that error? – kramer65 Feb 13 '18 at 12:46
  • I completely missed that you tried that already...Can you try purging them all in one command like I updated? – HoD Feb 13 '18 at 14:02
  • I edited again asking about the Debian repos, seems fishy now that I think about it. – HoD Feb 13 '18 at 14:24
0

The firefox packages in the PureOS might be inconsistent or in a state of transition.

In this case, I suggest to remove the packages of iceweasel, firefox and firefox-esr (or all other variants of firefox), then download and install the latest Linux build of Firefox directly from Mozilla.
To terminate, check that automatic updates are enabled.

For more information see the Mozilla article Installing Firefox - Linux.

To remove a broken package, you may use the nuclear option of :

sudo dpkg --remove --force-remove-reinstreq package_name

If it gives you an error that it won't remove a package because it is depended on by another package, remove that other package as well.

harrymc
  • 455,459
  • 31
  • 526
  • 924
  • Thanks, but as you can read in the question I've tried removing all related browsers (firefox, firefox-esr, iceweasel and purebrowser) using both `apt remove` and `apt purge`. But that gives me some output, ending in the error `E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).` Any ideas how I can overcome that error? – kramer65 Feb 13 '18 at 12:46
  • Does the latest Linux build of Firefox from Mozilla work even if you don't remove these broken packages? – harrymc Feb 13 '18 at 13:06
  • You may also try `sudo dpkg --remove --force-remove-reinstreq package_name`. If it gives you an error that it won't remove a package because it is depended on by another package, remove that other package as well. – harrymc Feb 13 '18 at 14:29