Ubuntu – Mono broken after attempt to upgrade, unable to use apt

18.10aptmonopackage-management

I have had mono-complete and mono-devel installed on my Ubuntu Server 18.10 for a couple months now to run some applications that depend on it. I am using Mono 5.18.0.225. Prior to things breaking, I did a standard sudo apt update, saw many mono packages in the list to upgrade, then did a sudo apt upgrade. It went normally for most the install and then the terminal kept spitting out errors and errors and errors. The almost-endless errors would be printed out over and over for several seconds regardless of what I tried to do:

  • sudo apt upgrade
  • sudo apt –fix-broken install
  • sudo apt remove mono-complete mono-devel
  • sudo apt autoremove

Can't seem to upgrade or remove. If upgrading is impossible, I'd tried to remove and try a reinstall but removing failed too.

In the error it mentions not being able to find gdb or lldb. I then attempted to manually make and install gdb because I can't use apt… trying to do so will ask you to run sudo apt --fix-broken install which spits out the same errors. Installing gdb-8.2 is successful. The errors printed out change slightly and contain references to gdb (because now it's installed) but still haven't gotten anywhere.

  • How did mono break in the first place?
  • Why is trying to remove packages producing errors?
  • What's the best course of action to fix this situation? I'd rather not have to reinstall Ubuntu Server and set everything back up.

For what's being printed out in the error (before gdb install):

Aborted (core dumped)
E: installing Assembly /usr/share/cli-common/policies.d/libgtk2.0-cil/policy.2.8.gtk-sharp.dll failed
E: Installation of policy.2.8.gtk-sharp with /usr/share/cli-common/runtimes.d/mono failed
* Installing 1 assembly from policy.2.8.pango-sharp into Mono
Stacktrace:

/proc/self/maps:
41308000-41338000 rwxp 00000000 00:00 0
55b153398000-55b1537e1000 r-xp 00000000 08:02 3159129                    /usr/bin/mono-sgen

... cutting some of this out ...

7fb557c3b000-7fb557c88000 r--p 00000000 08:02 3160431                    /usr/lib/mono/gac/Mono.Security/4.0.0.0__0738eb9f132ed756/Mono.Security.dll
Memory around native instruction pointer (0x7fb5556e2c8f):
0x7fb5556e2c7f  20 48 09 d6 41 0f b6 53 05 48 c1 e2 28 48 09 f2   H..A..S.H..(H..
0x7fb5556e2c8f  66 41 0f 38 32 4b 06 66 0f 6f 05 b2 82 49 00 66  fA.82K.f.o...I.f
0x7fb5556e2c9f  0f 38 00 c8 66 48 0f 7e c8 66 48 0f 3a 16 ce 01  .8..fH.~.fH.:...
0x7fb5556e2caf  48 09 c6 48 09 d6 41 0f b6 c2 41 0f b6 53 09 48  H..H..A...A..S.H

Native stacktrace:

    /usr/bin/mono(+0x129f8d) [0x55b1534c1f8d]
    /usr/bin/mono(+0x12a295) [0x55b1534c2295]
    /usr/bin/mono(+0xbfd2f) [0x55b153457d2f]
    /usr/bin/mono(+0x414e8) [0x55b1533d94e8]
    /lib/x86_64-linux-gnu/libpthread.so.0(+0x12dd0) [0x7fb558343dd0]
    /usr/lib/mono/aot-cache/amd64/mscorlib.dll.so(+0x123c8f) [0x7fb5556e2c8f]

Waiting for dumping threads to resume


Debug info from gdb:

mono_gdb_render_native_backtraces not supported on this platform, unable to find gdb or lldb

=================================================================
Got a SIGILL while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================

Aborted (core dumped)
E: installing Assembly /usr/share/cli-common/policies.d/libgtk2.0-cil/policy.2.8.pango-sharp.dll failed
E: Installation of policy.2.8.pango-sharp with /usr/share/cli-common/runtimes.d/mono failed
^[[1mdpkg:^[[0m error processing package mono-gac (--configure):
installed mono-gac package post-installation script subprocess returned error exit status 29

Best Answer

I'm not 100% certain that these commands in this order will solve the problem every time but this is what happened and I was able to successfully reinstall Mono to get the applications that depend on it running again.

  1. sudo apt remove mono-complete mono-devel

    • Some packages should be removed (gets to about ~15-25%) before errors start spitting out and you can't run this again.
  2. sudo apt autoremove

    • Some packages should be removed before errors start spitting out and you can't run this again.
  3. sudo apt remove mono-gac mono-runtime-common
    • Some packages should be removed before errors start spitting out and you can't run this again.
  4. sudo apt autoremove
    • The rest of the Mono packages should remove completely this time without errors being spat out.
    • There must be certain package(s) that are the cause of the errors in the prior commands and when it's removed, the errors stop happening and the rest can be removed without issue.
  5. Reinstall Mono.
Related Question