運行/安裝 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
  libkf5declarative-data libkf5declarative5 libkf5doctools5
  libkf5globalaccel-資料 libkf5globalaccel5 libkf5globalaccelprivate5
  libkf5idletime5 libkf5jobwidgets-資料 libkf5jobwidgets5 libkf5kcmutils-數據
  libkf5kcmutils5 libkf5kiocore5 libkf5kiontlm5 libkf5kiowidgets5
  libkf5newstuff-資料 libkf5newstuff5 libkf5newstuffcore5 libkf5package-數據
  libkf5package5 libkf5plasma5 libkf5quickaddons5 libkf5solid5
  libkf5solid5-data libkf5sonnet5-data libkf5sonnetcore5 libkf5sonnetui5
  libkf5textwidgets-資料 libkf5textwidgets5 libkf5waylandclient5
  libkf5waylandserver5 libkf5xmlgui-bin libkf5xmlgui-data libkf5xmlgui5
  libkscreenlocker5 libkwin4-effect-builtins1 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 libqt5positioning5 libqt5printsupport5 libqt5qml5 libqt5quick5
  libqt5quickwidgets5 libqt5sensors5 libqt5sql5 libqt5test5 libqt5webchannel5
  libqt5webkit5 libxcb-composite0 libxcb-cursor0 libxcb-damage0 作業系統偵測器
  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-證書-mono
以下軟體包將會升級:
  ca-證書-mono
debconf:由於未安裝 apt-utils,因此延遲了軟體包配置
1 已升級,0 已新安裝,0 已刪除,278 未升級。
157 未完全安裝或移除。
需要取得 0 B/31.2 kB 的檔案。
執行此操作後,將釋放4096B磁碟空間。
設定 mono-gac (6.0.0.313-0xamarin3+ubuntu1804b1) ...
* 將 1 個組件從 libnewtonsoft-json5.0-cil 安裝到 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 安靜)[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 安靜)[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 安靜)[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 安靜)[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):
 依賴性問題 - 未配置
未寫入批准報告,因為錯誤訊息表明它是先前故障的後續錯誤。
處理時遇到錯誤:
 單一活性碳
 單一運行時通用
E: 子進程 /usr/bin/dpkg 回傳錯誤代碼 (1)

答案1

我在以前運行良好的腳本上也遇到過這個問題。這是由於 Mono 從 5.18.0.x 升級到最近發布的 6.0.0(2019 年 7 月 14 日)。

我能夠使用 NuGet 4.7.0.5148(在 OSX 上)和 5.1.0.6013(在 Ubuntu 18.04 上)重現該錯誤。

在我的 Mac 上成功將 Mono 降級到 5.18.1 後,腳本再次運行。目前我仍然停留在 Ubuntu 18.04 上,因為降級的 Mono 現在遇到了 libc 異常。

相關內容