Obteniendo una excepción no controlada al ejecutar/instalar nuget

Obteniendo una excepción no controlada al ejecutar/instalar nuget

Intentando instalar nuget en Ubuntu 18.04.2 LTS. Recibo errores y no sé cómo reparar las cosas desde este estado.

nuget no se inicia, muestra el siguiente error de excepción no controlada sobre System.Console.

Unhandled Exception:
System.TypeInitializationException: The type initializer for 'System.Console' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.ConsoleDriver' threw an exception. ---> System.DllNotFoundException: System.Native
  at (wrapper managed-to-native) Interop+Sys.Stat(byte&,Interop/Sys/FileStatus&)
  at Interop+Sys.Stat (System.ReadOnlySpan`1[T] path, Interop+Sys+FileStatus& output) [0x00028] in <81342d83acda4c5590ec19c7afdf26b9>:0
  at System.IO.FileSystem.FileExists (System.ReadOnlySpan`1[T] fullPath, System.Int32 fileType, Interop+ErrorInfo& errorInfo) [0x00007] in <81342d83acda4c5590ec19c7afdf26b9>:0
  at System.IO.FileSystem.DirectoryExists (System.ReadOnlySpan`1[T] fullPath, Interop+ErrorInfo& errorInfo) [0x00000] in <81342d83acda4c5590ec19c7afdf26b9>:0
  at System.IO.FileSystem.DirectoryExists (System.ReadOnlySpan`1[T] fullPath) [0x00000] in <81342d83acda4c5590ec19c7afdf26b9>:0
  at System.IO.Directory.Exists (System.String path) [0x0001e] in <81342d83acda4c5590ec19c7afdf26b9>:0
  at System.TermInfoDriver.SearchTerminfo (System.String term) [0x00044] in <81342d83acda4c5590ec19c7afdf26b9>:0
  at System.TermInfoDriver..ctor (System.String term) [0x0004b] in <81342d83acda4c5590ec19c7afdf26b9>:0
  at System.ConsoleDriver.CreateTermInfoDriver (System.String term) [0x00000] in <81342d83acda4c5590ec19c7afdf26b9>:0
  at System.ConsoleDriver..cctor () [0x0004d] in <81342d83acda4c5590ec19c7afdf26b9>:0
   --- End of inner exception stack trace ---
  at System.Console.SetupStreams (System.Text.Encoding inputEncoding, System.Text.Encoding outputEncoding) [0x00007] in <81342d83acda4c5590ec19c7afdf26b9>:0
  at System.Console..cctor () [0x0007d] in <81342d83acda4c5590ec19c7afdf26b9>:0
   --- End of inner exception stack trace ---
  at NuGet.Program.Main (System.String[] args) [0x00005] in <dc8a236afba24badbb185682f8956bec>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'System.Console' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.ConsoleDriver' threw an exception. ---> System.DllNotFoundException: System.Native
  at (wrapper managed-to-native) Interop+Sys.Stat(byte&,Interop/Sys/FileStatus&)
  at Interop+Sys.Stat (System.ReadOnlySpan`1[T] path, Interop+Sys+FileStatus& output) [0x00028] in <81342d83acda4c5590ec19c7afdf26b9>:0
  at System.IO.FileSystem.FileExists (System.ReadOnlySpan`1[T] fullPath, System.Int32 fileType, Interop+ErrorInfo& errorInfo) [0x00007] in <81342d83acda4c5590ec19c7afdf26b9>:0
  at System.IO.FileSystem.DirectoryExists (System.ReadOnlySpan`1[T] fullPath, Interop+ErrorInfo& errorInfo) [0x00000] in <81342d83acda4c5590ec19c7afdf26b9>:0
  at System.IO.FileSystem.DirectoryExists (System.ReadOnlySpan`1[T] fullPath) [0x00000] in <81342d83acda4c5590ec19c7afdf26b9>:0
  at System.IO.Directory.Exists (System.String path) [0x0001e] in <81342d83acda4c5590ec19c7afdf26b9>:0
  at System.TermInfoDriver.SearchTerminfo (System.String term) [0x00044] in <81342d83acda4c5590ec19c7afdf26b9>:0
  at System.TermInfoDriver..ctor (System.String term) [0x0004b] in <81342d83acda4c5590ec19c7afdf26b9>:0
  at System.ConsoleDriver.CreateTermInfoDriver (System.String term) [0x00000] in <81342d83acda4c5590ec19c7afdf26b9>:0
  at System.ConsoleDriver..cctor () [0x0004d] in <81342d83acda4c5590ec19c7afdf26b9>:0
   --- End of inner exception stack trace ---
  at System.Console.SetupStreams (System.Text.Encoding inputEncoding, System.Text.Encoding outputEncoding) [0x00007] in <81342d83acda4c5590ec19c7afdf26b9>:0
  at System.Console..cctor () [0x0007d] in <81342d83acda4c5590ec19c7afdf26b9>:0
   --- End of inner exception stack trace ---
  at NuGet.Program.Main (System.String[] args) [0x00005] in <dc8a236afba24badbb185682f8956bec>:0

Para intentar solucionarlo, hice esto:

sudo apt --fix-broken install -y >log.txt 2>&1

Y aquí está el log.txt. Lo siento, es brutalmente largo, pero no estoy seguro de qué partes son relevantes.

ADVERTENCIA: apt no tiene una interfaz CLI estable. Úselo con precaución en los guiones.

Leyendo listas de paquetes...
Construyendo árbol de dependencia...
Leyendo información del estado...
Corrigiendo dependencias... Hecho
Los siguientes paquetes se instalaron automáticamente y ya no son necesarios:
  apt-clone archdetect-deb ocupadobox-estático cryptsetup-bin dpkg-repack
  gir1.2-timezonemap-1.0 gir1.2-xkl-1.0 grub-common kde-window-manager kinit
  kio kpackagetool5 kwayland-data kwin-common kwin-data kwin-x11
  libdebian-installer4 libkdecorations2-5v5 libkdecorations2private5v5
  libkf5actividades5 libkf5attica5 libkf5completion-data libkf5completion5
  libkf5datos-declarativos libkf5declarativo5 libkf5doctools5
  libkf5globalaccel-datos libkf5globalaccel5 ​​libkf5globalaccelprivate5
  libkf5idletime5 libkf5jobwidgets-data libkf5jobwidgets5 libkf5kcmutils-data
  libkf5kcmutils5 libkf5kiocore5 libkf5kiontlm5 libkf5kiowidgets5
  libkf5newstuff-data libkf5newstuff5 libkf5newstuffcore5 libkf5package-datos
  libkf5package5 libkf5plasma5 libkf5quickaddons5 libkf5solid5
  libkf5solid5-datos libkf5sonnet5-datos libkf5sonnetcore5 libkf5sonnetui5
  libkf5textwidgets-datos libkf5textwidgets5 libkf5waylandclient5
  libkf5waylandserver5 libkf5xmlgui-bin libkf5xmlgui-data libkf5xmlgui5
  libkscreenlocker5 libkwin4-efecto-integrados1 libkwineffects11
  libkwinglutils11 libkwinxrenderutils11
  libmono-system-runtime-interopservices-runtimeinformation4.0-cil
  libnunit-cil-dev libnunit-console-runner2.6.3-cil
  libnunit-core-interfaces2.6.3-cil libnunit-core2.6.3-cil
  libnunit-framework2.6.3-cil libnunit-mocks2.6.3-cil libnunit-util2.6.3-cil
  libqgsttools-p1 libqt5designer5 libqt5help5 libqt5multimedia5
  libqt5multimedia5-plugins libqt5multimediaquick-p5 libqt5multimediawidgets5
  libqt5opengl5 libqt5posicionamiento5 libqt5printsupport5 libqt5qml5 libqt5quick5
  libqt5quickwidgets5 libqt5sensors5 libqt5sql5 libqt5test5 libqt5webchannel5
  libqt5webkit5 libxcb-composite0 libxcb-cursor0 libxcb-damage0 os-prober
  python3-dbus.mainloop.pyqt5 python3-icu python3-pam python3-pyqt5
  python3-pyqt5.qtsvg python3-pyqt5.qtwebkit python3-sip
  módulo-qml-org-kde-kquickcontrolsaddons módulo-qml-qtmultimedia
  módulo-qml-qtquick2 rdate
Utilice 'sudo apt autoremove' para eliminarlos.
Se instalarán los siguientes paquetes adicionales:
  certificados-ca-mono
Se actualizarán los siguientes paquetes:
  certificados-ca-mono
debconf: retrasa la configuración del paquete, ya que apt-utils no está instalado
1 actualizado, 0 recién instalados, 0 para eliminar y 278 no actualizados.
157 no completamente instalado o eliminado.
Necesita obtener 0 B/31,2 kB de archivos.
Después de esta operación, se liberarán 4.096 B de espacio en disco.
Configurando mono-gac (6.0.0.313-0xamarin3+ubuntu1804b1)...
* Instalación de 1 ensamblaje de libnewtonsoft-json5.0-cil en Mono

Excepción no controlada:
System.DllNotFoundException: System.Nativo
  en (contenedor administrado a nativo) Interop+Sys.Stat(byte&,Interop/Sys/FileStatus&)
  en Interop+Sys.Stat (ruta System.ReadOnlySpan`1[T], Interop+Sys+FileStatus y salida) [0x00028] en :0
  en System.IO.FileSystem.FileExists (System.ReadOnlySpan`1[T] fullPath, System.Int32 fileType, Interop+ErrorInfo& errorInfo) [0x00007] en:0
  en System.IO.FileSystem.FileExists (System.ReadOnlySpan`1[T] fullPath) [0x00006] en:0
  en System.IO.File.Exists (ruta System.String) [0x00043] en:0
  en Mono.Tools.Driver.LoadConfig (System.Boolean quiet) [0x00028] en:0
  en Mono.Tools.Driver.Main (System.String[] args) [0x00351] en:0
[ERROR] EXCEPCIÓN GRAVE NO MANEJADA: System.DllNotFoundException: System.Native
  en (contenedor administrado a nativo) Interop+Sys.Stat(byte&,Interop/Sys/FileStatus&)
  en Interop+Sys.Stat (ruta System.ReadOnlySpan`1[T], Interop+Sys+FileStatus y salida) [0x00028] en :0
  en System.IO.FileSystem.FileExists (System.ReadOnlySpan`1[T] fullPath, System.Int32 fileType, Interop+ErrorInfo& errorInfo) [0x00007] en:0
  en System.IO.FileSystem.FileExists (System.ReadOnlySpan`1[T] fullPath) [0x00006] en:0
  en System.IO.File.Exists (ruta System.String) [0x00043] en:0
  en Mono.Tools.Driver.LoadConfig (System.Boolean quiet) [0x00028] en:0
  en Mono.Tools.Driver.Main (System.String[] args) [0x00351] en:0
E: Error al instalar el ensamblaje /usr/lib/cli/Newtonsoft.Json-5.0/Newtonsoft.Json.dll
E: Error en la instalación de libnewtonsoft-json5.0-cil con /usr/share/cli-common/runtimes.d/mono
* Instalación de 1 ensamblaje de libnunit-console-runner2.6.3-cil en Mono

...se eliminaron muchas excepciones similares...

Excepción no controlada:
System.DllNotFoundException: System.Nativo
  en (contenedor administrado a nativo) Interop+Sys.Stat(byte&,Interop/Sys/FileStatus&)
  en Interop+Sys.Stat (ruta System.ReadOnlySpan`1[T], Interop+Sys+FileStatus y salida) [0x00028] en :0
  en System.IO.FileSystem.FileExists (System.ReadOnlySpan`1[T] fullPath, System.Int32 fileType, Interop+ErrorInfo& errorInfo) [0x00007] en:0
  en System.IO.FileSystem.FileExists (System.ReadOnlySpan`1[T] fullPath) [0x00006] en:0
  en System.IO.File.Exists (ruta System.String) [0x00043] en:0
  en Mono.Tools.Driver.LoadConfig (System.Boolean quiet) [0x00028] en:0
  en Mono.Tools.Driver.Main (System.String[] args) [0x00351] en:0
[ERROR] EXCEPCIÓN GRAVE NO MANEJADA: System.DllNotFoundException: System.Native
  en (contenedor administrado a nativo) Interop+Sys.Stat(byte&,Interop/Sys/FileStatus&)
  en Interop+Sys.Stat (ruta System.ReadOnlySpan`1[T], Interop+Sys+FileStatus y salida) [0x00028] en :0
  en System.IO.FileSystem.FileExists (System.ReadOnlySpan`1[T] fullPath, System.Int32 fileType, Interop+ErrorInfo& errorInfo) [0x00007] en:0
  en System.IO.FileSystem.FileExists (System.ReadOnlySpan`1[T] fullPath) [0x00006] en:0
  en System.IO.File.Exists (ruta System.String) [0x00043] en:0
  en Mono.Tools.Driver.LoadConfig (System.Boolean quiet) [0x00028] en:0
  en Mono.Tools.Driver.Main (System.String[] args) [0x00351] en:0
E: falló la instalación del ensamblado /usr/share/cli-common/policies.d/libnewtonsoft-json5.0-cil/policy.5.0.Newtonsoft.Json.dll
E: Error en la instalación de Policy.5.0.Newtonsoft.Json con /usr/share/cli-common/runtimes.d/mono
dpkg: error al procesar el paquete mono-gac (--configure):
 El subproceso del script posterior a la instalación del paquete mono-gac instalado devolvió el estado de salida de error 29
dpkg: los problemas de dependencia impiden la configuración de mono-runtime-common:
 mono-runtime-common depende de mono-gac (= 6.0.0.313-0xamarin3+ubuntu1804b1); sin embargo:
  El paquete mono-gac aún no está configurado.

dpkg: error al procesar el paquete mono-runtime-common (--configure):
 problemas de dependencia - dejar sin configurar
No se ha escrito ningún informe porque el mensaje de error indica que se trata de un error de seguimiento de una falla anterior.
Se encontraron errores al procesar:
 mono-gac
 mono-runtime-común
E: El subproceso /usr/bin/dpkg devolvió un código de error (1)

Respuesta1

También me encontré con esto en un script que anteriormente funcionaba bien. Esto se debe a una actualización de Mono de 5.18.0.x a 6.0.0 que se lanzó recientemente (14 de julio de 2019).

Pude reproducir el error tanto con NuGet 4.7.0.5148 (en OSX) como con 5.1.0.6013 (en Ubuntu 18.04).

Después de lograr degradar Mono a 5.18.1 en mi Mac, el script volvió a funcionar. Actualmente todavía estoy atascado en Ubuntu 18.04, ya que el Mono degradado ahora tiene excepciones de libc.

información relacionada