我使用的是 PureOS,它基本上是 Debian,但做了一些小调整。我尝试在其上安装 Firefox,但结果一团糟。如果我现在尝试进行基本升级,我会得到以下信息:
$ 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).
所以我尝试提出建议:
$ 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)
现在我有点陷入困境。
有人知道我该怎么做才能清理这个烂摊子吗?欢迎提供各种建议!
[编辑]
我尝试过多种方法来删除 Firefox:
$ 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).
我也尝试了以下变化,但都给出了类似的结果:
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
[编辑2]
根据@alan的回答,我尝试消除转移:
$ sudo dpkg-divert --remove /usr/bin/firefox
Removing 'diversion of /usr/bin/firefox to /usr/bin/firefox.real by purebrowser'
之后我进行了更新,然后进行了升级:
$ 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).
不幸的是,结果和你看到的一样。我试了apt --fix-broken install
一下以确保万无一失,但结果和以前一样。
因此我使用该命令来查找其他改道(尽管我不能 100% 确定改道到底是什么):
& 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
所以我只是填写了我认为正确的内容:
$ 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'
但我又得到了同样的结果:
$ 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).
并再次尝试修复它:
$ 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)
还有其他建议吗?
[编辑 3]
按照@harrymc 的提示,我尝试运行以下命令:
$ 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).
正如你所见,这并没有起到作用。所以这是输出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
仅供参考,以下是我的内容/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
这能告诉你什么吗?
答案1
Firefox 正在尝试创建一个转移,但同名的转移已存在。
您需要先移除现有的转移。
这是错误行:
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'
sudo dpkg-divert --remove /usr/bin/firefox
注意:如果转移不是由 /usr/bin/firefox 引起的,您可能需要使用sudo dpkg-divert --list | grep firefox
或sudo dpkg-divert --list | grep purebrowser
来识别转移。另外,如果您不喜欢 Perl 抛出的语言环境错误消息,您可以通过导出语言环境来摆脱它,如下所示这里:
export LC_CTYPE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
如果其他方法都失败了,请打开包记录并手动删除 iceweasel:
sudo -i gedit /var/lib/dpkg/status
(您可能会看到一个以类似“Package: Iceweasel Status: Install broken”开头的块。请参阅此类似问题:无法使用 sudo apt-get install -f 修复损坏的软件包
答案2
使用这个:
sudo dpkg -i --force-all /var/cache/apt/archives/firefox-esr_52.6.0esr-1~deb9u1_amd64.deb
你将强制安装 firefox-esr。99.9% 它会解决你的问题。然后继续
sudo dpkg --configure -a
,你很可能就会没事了。
一般来说,在安装中混合东西时,你会发现一个包需要覆盖另一个包中的文件。在这些情况下使用dpkg
with--force-all
选项可以让你扮演上帝,但它也会推翻 Debian 包管理系统中内置的所有那些很好的安全检查。但毕竟,这是成为根用户。
答案3
查看存储库时,Debian 包含“Iceweasel”包,而 PureOS 存储库包含 firefox-esr 包。根据错误消息,它们是冲突的。
这可能会删除你的 Firefox 配置文件,但我会尝试:
sudo apt purge firefox firefox-esr iceweasel purebrowser
sudo apt install firefox-esr
这应该会从 PureOS repo 安装 Firefox 包。
Iceweasel 是 Debian 对 Firefox 的品牌重塑,但他们正在撤销这些更改。在 Debian 中,它仍称为 Iceweasel,但它只是安装了一个修补的 firefox-esr,在下一个 Debian 版本中,它应该简称为 firefox-esr。
您是否有可能自己添加了这些 Debian 存储库?混合发行版存储库从来都不是一个好主意。然后注释掉这些行:
apt clean && apt update
然后再次尝试清除并安装。
答案4
PureOS 中的 Firefox 包可能不一致或处于过渡状态。
在这种情况下,我建议删除 iceweasel、firefox 和 firefox-esr(或所有其他 Firefox 变体)的软件包,然后下载并安装
直接从 Mozilla 获得最新的 Linux 版本的 Firefox。
要终止,请检查是否启用了自动更新。
有关详细信息,请参阅 Mozilla 文章 安装 Firefox - Linux。
要删除损坏的包裹,您可以使用以下核选项:
sudo dpkg --remove --force-remove-reinstreq package_name
如果它给您一个错误,说它不会删除一个包,因为它依赖于另一个包,那么也请删除那个其他包。