NuGet の実行/インストール中に未処理の例外が発生する

NuGet の実行/インストール中に未処理の例外が発生する

Ubuntu 18.04.2 LTS に nuget をインストールしようとしています。エラーが発生しており、この状態から修復する方法がわかりません。

nuget が起動しない場合、次のような未処理の例外エラーが発生します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

これを修正するために、私は次のことを実行しました:

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

そして、これが log.txt です。申し訳ありませんが、非常に長いのですが、どの部分が関連しているかわかりません。

警告: apt には安定した CLI インターフェースがありません。スクリプトでは注意して使用してください。

パッケージリストを読み込んでいます...
依存関係ツリーを構築しています...
状態情報を読み取っています...
依存関係を修正しています...完了
次のパッケージは自動的にインストールされ、不要になりました。
  apt-clone archdetect-deb busybox-static 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
  libkf5activities5 libkf5attica5 libkf5completion-data libkf5completion5
  libkf5宣言型データ libkf5宣言型5 libkf5doctools5
  libkf5globalaccel-data libkf5globalaccel5 libkf5globalaccelprivate5
  libkf5idletime5 libkf5jobwidgets-データ libkf5jobwidgets5 libkf5kcmutils-データ
  libkf5kcmutils5 libkf5kiocore5 libkf5kiontlm5 libkf5kiowidgets5
  libkf5newstuff-data libkf5newstuff5 libkf5newstuffcore5 libkf5package-data
  libkf5package5 libkf5plasma5 libkf5quickaddons5 libkf5solid5
  libkf5solid5-データ libkf5sonnet5-データ libkf5sonnetcore5 libkf5sonnetui5
  libkf5textwidgets-データ libkf5textwidgets5 libkf5waylandclient5
  libkf5waylandserver5 libkf5xmlgui-bin libkf5xmlgui-data libkf5xmlgui5
  libkscreenlocker5 libkwin4-effect-builtins1 libkwineffects11
  libkwinglutils11 libkwinxrenderutils11
  libmono-システム-ランタイム-相互運用サービス-ランタイム情報4.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-プラグイン libqt5multimediaquick-p5 libqt5multimediawidgets5
  libqt5opengl5 libqt5positioning5 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
  qml-module-org-kde-kquickcontrolsaddons qml-module-qtmultimedia
  qml-モジュール-qtquick2 rdate
削除するには、「sudo apt autoremove」を使用します。
次の追加パッケージがインストールされます:
  ca-証明書-モノ
以下のパッケージがアップグレードされます:
  ca-証明書-モノ
debconf: apt-utils がインストールされていないため、パッケージの設定を遅延しています
アップグレードされたものが 1 つ、新規にインストールされたものが 0 つ、削除されたものが 0 つ、アップグレードされていないものが 278 つ。
157 が完全にインストールまたは削除されていません。
0 B/31.2 kB のアーカイブを取得する必要があります。
この操作の後、4,096 B のディスク領域が解放されます。
mono-gac (6.0.0.313-0xamarin3+ubuntu1804b1) をセットアップしています...
* libnewtonsoft-json5.0-cil から 1 つのアセンブリを Mono にインストールする

未処理の例外:
System.DllNotFoundException: System.Native
  at (マネージドからネイティブへのラッパー) Interop+Sys.Stat(byte&,Interop/Sys/FileStatus&)
  Interop+Sys.Stat (System.ReadOnlySpan`1[T] パス、Interop+Sys+FileStatus& 出力) [0x00028] :0 で
  System.IO.FileSystem.FileExists (System.ReadOnlySpan`1[T] fullPath、System.Int32 fileType、Interop+ErrorInfo& errorInfo) [0x00007] で:0
  System.IO.FileSystem.FileExists (System.ReadOnlySpan`1[T] fullPath) [0x00006] で:0
  System.IO.File.Exists (System.String パス) [0x00043] :0
  Mono.Tools.Driver.LoadConfig (System.Boolean quiet) [0x00028] :0 で
  Mono.Tools.Driver.Main (System.String[] args) [0x00351] で:0
[エラー] 致命的な未処理の例外: System.DllNotFoundException: System.Native
  at (マネージドからネイティブへのラッパー) Interop+Sys.Stat(byte&,Interop/Sys/FileStatus&)
  Interop+Sys.Stat (System.ReadOnlySpan`1[T] パス、Interop+Sys+FileStatus& 出力) [0x00028] :0 で
  System.IO.FileSystem.FileExists (System.ReadOnlySpan`1[T] fullPath、System.Int32 fileType、Interop+ErrorInfo& errorInfo) [0x00007] で:0
  System.IO.FileSystem.FileExists (System.ReadOnlySpan`1[T] fullPath) [0x00006] で:0
  System.IO.File.Exists (System.String パス) [0x00043] :0
  Mono.Tools.Driver.LoadConfig (System.Boolean quiet) [0x00028] :0 で
  Mono.Tools.Driver.Main (System.String[] args) [0x00351] で:0
E: アセンブリ /usr/lib/cli/Newtonsoft.Json-5.0/Newtonsoft.Json.dll のインストールに失敗しました
E: /usr/share/cli-common/runtimes.d/mono を使用した libnewtonsoft-json5.0-cil のインストールに失敗しました
* libnunit-console-runner2.6.3-cil から 1 つのアセンブリを Mono にインストールする

...多くの同様の例外が削除されました...

未処理の例外:
System.DllNotFoundException: System.Native
  at (マネージドからネイティブへのラッパー) Interop+Sys.Stat(byte&,Interop/Sys/FileStatus&)
  Interop+Sys.Stat (System.ReadOnlySpan`1[T] パス、Interop+Sys+FileStatus& 出力) [0x00028] :0 で
  System.IO.FileSystem.FileExists (System.ReadOnlySpan`1[T] fullPath、System.Int32 fileType、Interop+ErrorInfo& errorInfo) [0x00007] で:0
  System.IO.FileSystem.FileExists (System.ReadOnlySpan`1[T] fullPath) [0x00006] で:0
  System.IO.File.Exists (System.String パス) [0x00043] :0
  Mono.Tools.Driver.LoadConfig (System.Boolean quiet) [0x00028] :0 で
  Mono.Tools.Driver.Main (System.String[] args) [0x00351] で:0
[エラー] 致命的な未処理の例外: System.DllNotFoundException: System.Native
  at (マネージドからネイティブへのラッパー) Interop+Sys.Stat(byte&,Interop/Sys/FileStatus&)
  Interop+Sys.Stat (System.ReadOnlySpan`1[T] パス、Interop+Sys+FileStatus& 出力) [0x00028] :0 で
  System.IO.FileSystem.FileExists (System.ReadOnlySpan`1[T] fullPath、System.Int32 fileType、Interop+ErrorInfo& errorInfo) [0x00007] で:0
  System.IO.FileSystem.FileExists (System.ReadOnlySpan`1[T] fullPath) [0x00006] で:0
  System.IO.File.Exists (System.String パス) [0x00043] :0
  Mono.Tools.Driver.LoadConfig (System.Boolean quiet) [0x00028] :0 で
  Mono.Tools.Driver.Main (System.String[] args) [0x00351] で:0
E: アセンブリ /usr/share/cli-common/policies.d/libnewtonsoft-json5.0-cil/policy.5.0.Newtonsoft.Json.dll のインストールに失敗しました
E: /usr/share/cli-common/runtimes.d/mono を使用した policy.5.0.Newtonsoft.Json のインストールに失敗しました
dpkg: パッケージ mono-gac (--configure) の処理中にエラーが発生しました:
 mono-gac パッケージをインストールしました。インストール後のスクリプト サブプロセスがエラー終了ステータス 29 を返しました。
dpkg: 依存関係の問題により mono-runtime-common の構成が妨げられます:
 mono-runtime-common は mono-gac (= 6.0.0.313-0xamarin3+ubuntu1804b1) に依存しますが、次の点が異なります。
  パッケージ mono-gac はまだ構成されていません。

dpkg: パッケージ mono-runtime-common (--configure) の処理中にエラーが発生しました:
 依存関係の問題 - 未設定のままにする
エラー メッセージに以前の失敗に続くエラーであることが示されているため、apport レポートは書き込まれません。
処理中にエラーが発生しました:
 モノガック
 モノランタイム共通
E: サブプロセス /usr/bin/dpkg がエラーコードを返しました (1)

答え1

以前は問題なく動作していたスクリプトでも、この問題に遭遇しました。これは、最近リリースされた (2019 年 7 月 14 日) Mono の 5.18.0.x から 6.0.0 へのアップグレードが原因です。

NuGet 4.7.0.5148 (OSX 上) と 5.1.0.6013 (Ubuntu 18.04 上) の両方でエラーを再現できました。

私の Mac で Mono を 5.18.1 にダウングレードした後、スクリプトは再び機能しました。ただし、ダウングレードした Mono で libc 例外が発生しているため、現在も Ubuntu 18.04 で止まっています。

関連情報