尝试安装 mono。现在 apt 坏了

尝试安装 mono。现在 apt 坏了

我尝试为 Ubuntu 20.04 安装 mono。我使用了这些命令。

sudo apt install gnupg ca-certificates
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb https://download.mono-project.com/repo/ubuntu stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
sudo apt update

之后我运行了这个命令sudo apt install mono-devel并得到了这个输出:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 libmono-corlib4.5-cil : Depends: mono-runtime (< 6.8.0.106) but 6.12.0.122-0xamarin1+ubuntu2004b1 is to be installed
 mono-devel : Depends: libmono-cecil-private-cil (>= 6.12.0.122) but it is not going to be installed
              Depends: libmono-cecil-private-cil (< 6.12.0.123) but it is not going to be installed
              Depends: libmono-codecontracts4.0-cil (>= 1.0) but it is not going to be installed
              Depends: libmono-compilerservices-symbolwriter4.0-cil (>= 3.6.0) but it is not going to be installed
              Depends: libmono-peapi4.0a-cil (>= 3.2.8) but it is not going to be installed
              Depends: libmono-relaxng4.0-cil (>= 2.10.1) but it is not going to be installed
              Depends: libmono-system-configuration-install4.0-cil (>= 1.0) but it is not going to be installed
              Depends: libmono-system-io-compression-filesystem4.0-cil (>= 3.2.1) but it is not going to be installed
              Depends: libmono-system-runtime4.0-cil (>= 2.10.1) but it is not going to be installed
              Depends: libmono-system-servicemodel4.0a-cil (>= 3.2.3) but it is not going to be installed
              Depends: mono-mcs (= 6.12.0.122-0xamarin1+ubuntu2004b1) but it is not going to be installed
              Depends: mono-roslyn (= 6.12.0.122-0xamarin1+ubuntu2004b1) but it is not going to be installed
              Depends: mono-xbuild (= 6.12.0.122-0xamarin1+ubuntu2004b1) but it is not going to be installed
              Depends: libmono-cil-dev (= 6.12.0.122-0xamarin1+ubuntu2004b1) but it is not going to be installed
              Depends: libmono-2.0-dev (>= 6.12.0.122-0xamarin1+ubuntu2004b1) but it is not going to be installed
              Depends: libmono-2.0-dev (< 6.12.0.122-0xamarin1+ubuntu2004b1.1~) but it is not going to be installed
              Depends: ca-certificates-mono (= 6.12.0.122-0xamarin1+ubuntu2004b1) but 6.8.0.105+dfsg-3.2 is to be installed
              Recommends: mono-csharp-shell but it is not going to be installed
              Recommends: referenceassemblies-pcl but it is not going to be installed
              Recommends: msbuild but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

如果我运行apt --fix-broken install我会得到这个输出:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Correcting dependencies... Done
The following package was automatically installed and is no longer required:
  libmono-corlib4.5-dll
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  libmono-corlib4.5-cil
The following packages will be upgraded:
  libmono-corlib4.5-cil
1 upgraded, 0 newly installed, 0 to remove and 9 not upgraded.
37 not fully installed or removed.
Need to get 0 B/1,257 kB of archives.
After this operation, 4,620 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
dpkg: warning: files list file for package 'mono-runtime-common' missing; assuming package has no files currently installed
(Reading database ... 310583 files and directories currently installed.)
Preparing to unpack .../libmono-corlib4.5-cil_6.12.0.122-0xamarin1+ubuntu2004b1_all.deb ...
Unpacking libmono-corlib4.5-cil (6.12.0.122-0xamarin1+ubuntu2004b1) over (6.8.0.105+dfsg-3.2) ...
dpkg: error processing archive /var/cache/apt/archives/libmono-corlib4.5-cil_6.12.0.122-0xamarin1+ubuntu2004b1_all.deb (--unpack):
 trying to overwrite '/usr/lib/mono/4.5/mscorlib.dll', which is also in package libmono-corlib4.5-dll 6.8.0.105+dfsg-3.2
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/libmono-corlib4.5-cil_6.12.0.122-0xamarin1+ubuntu2004b1_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

如果我运行apt autoremove我会得到这个输出:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 libmono-corlib4.5-cil : Depends: mono-runtime (< 6.8.0.106) but 6.12.0.122-0xamarin1+ubuntu2004b1 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

我实际上不再想要单声道了,只想删除它并解决这个问题。

答案1

我通过手动删除目录/usr/share/libmono-corlib4.5-cil和解决了该问题/usr/share/libmono-corlib4.5-dll

之后我运行了以下命令:

sudo apt update
sudo apt install libmono-corlib4.5-cil
sudo apt update
sudo apt --fix-broken install
sudo apt autoremove
sudo apt update
sudo apt full-upgrade
sudo rm /etc/apt/sources.list.d/mono-official-stable.list
sudo apt-key del 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
sudo apt update
sudo apt full-upgrade

这解决了我所有的问题。

相关内容