创建新的 dotnet 项目时如何修复 "Segmentation fault (core dumped)"?

How to fix "Segmentation fault (core dumped)" when creating new dotnet project?

我关注https://dotnet.microsoft.com/learn/dotnet/hello-world-tutorial/create

当我尝试创建项目时,我得到以下信息:

oskar@oskarslaptop:~/Programming/Resorvoir-CLI$ dotnet new console -o MyApp
Segmentation fault (core dumped)

我已经使用 snap 安装了 dotnet 5.0:

sudo snap install dotnet-sdk --classic --channel=5.0
sudo snap alias dotnet-sdk.dotnet dotnet

快照信息:

oskar@oskarslaptop:~/Programming/Resorvoir-CLI$ sudo snap info dotnet-sdk 
name:      dotnet-sdk
summary:   Develop high performance applications in less time, on any platform.
publisher: Microsoft .NET Core (dotnetcore✓)
store-url: https://snapcraft.io/dotnet-sdk
contact:   https://dot.net/core
license:   unset
description: |
  .NET Core is the modular and high performance implementation of .NET for creating web applications
  and services that run on Windows, Linux and Mac. It is open source and it can share the same code
  with .NET Framework and Xamarin apps.
  
  .NET Core is a .NET Foundation project. https://dotnetfoundation.org/
commands:
  - dotnet-sdk.dotnet
snap-id:      uHc4y9lWxyqYfxsqcr4xILzAai4L1BHs
tracking:     5.0/stable
refresh-date: today at 13:36 BST
channels:
  latest/stable:    5.0.302                   2021-07-13 (132) 139MB classic
  latest/candidate: ↑                                                
  latest/beta:      ↑                                                
  latest/edge:      5.0.202                   2021-04-16 (120) 137MB classic
  lts/stable:       3.1.411                   2021-07-13 (133) 123MB classic
  lts/candidate:    ↑                                                
  lts/beta:         ↑                                                
  lts/edge:         ↑                                                
  6.0/stable:       –                                                
  6.0/candidate:    –                                                
  6.0/beta:         6.0.100-preview.6.21355.2 2021-07-14 (134) 144MB classic
  6.0/edge:         ↑                                                
  5.0/stable:       5.0.302                   2021-07-13 (132) 139MB classic
  5.0/candidate:    ↑                                                
  5.0/beta:         5.0.100                   2020-11-10 (105) 267MB classic
  5.0/edge:         ↑                                                
  3.1/stable:       3.1.411                   2021-07-13 (133) 123MB classic
  3.1/candidate:    ↑                                                
  3.1/beta:         ↑                                                
  3.1/edge:         ↑                                                
  2.1/stable:       2.1.816                   2021-05-11 (124) 245MB classic
  2.1/candidate:    ↑                                                
  2.1/beta:         ↑                                                
  2.1/edge:         2.1.808                   2020-07-14  (91) 245MB classic
installed:          5.0.302                              (132) 139MB classic

我认为这是 snap 本身的问题。而不是 snap ,使用 pacman

sudo snap remove dotnet-sdk
sudo pacman -S dotnet-sdk

这里有关于这个问题的更多信息 https://github.com/dotnet/sdk/issues/11639

POP OS 基于 Ubuntu。如果您通过 snap install 安装了 dotnet 运行时,您只能通过“sudo dotnet ...”访问它。我在 VS Code 中遇到了同样的问题,它在没有 sudo 的情况下运行 dotnet 命令,我收到了“Segmentation fault (core dumped)”错误。我通过 apt-get 安装 dotnet 运行时解决了(现在安装在“/usr/bin ...”中并且没有 sudo 工作(参见:https://docs.microsoft.com/en-us/dotnet/core/install/linux-ubuntu#2004-))

我在 Ubuntu 22.04 上使用 .Net 6.0(dotnet 构建)获得 'Segmentation fault (core dumped)'。 降级到 Ubuntu 20.04 后。 'dotnet build'效果不错