sdk: Installed .NET 6.0 SDKs not showing with dotnet --info or dotnet --list-sdks and commands depeding on SDK fail (Linux/Ubuntu)

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

[Ubuntu] After upgrade to latest dotnet sdk stopped working. Clean reinstall of latest version doesn’t help.

dotnet-sdk-6.0/jammy,now 6.0.400-1 amd64 [installed]

dotnet --info output:

global.json file:
  Not found

Host:
  Version:      6.0.8
  Architecture: x64
  Commit:       55fb7ef977

.NET SDKs installed:
  No SDKs were found.

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.8 [/usr/lib/dotnet/dotnet6-6.0.108/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.8 [/usr/lib/dotnet/dotnet6-6.0.108/shared/Microsoft.NETCore.App]

Download .NET:
  https://aka.ms/dotnet-download

Learn about .NET Runtimes and SDKs:
  https://aka.ms/dotnet/runtimes-sdk-info

dotnet tools list

  * You intended to execute a .NET application:
      The application 'tools' does not exist.
  * You intended to execute a .NET SDK command:
      No .NET SDKs were found.

Download a .NET SDK:
https://aka.ms/dotnet-download

Learn about SDK resolution:
https://aka.ms/dotnet/sdk-not-found

Expected Behavior

dotnet SDK expected to be working after install or upgrade

Steps To Reproduce

Installed according to instruction for the ubuntu 22.04: https://docs.microsoft.com/en-us/dotnet/core/install/linux-ubuntu#2204

Exceptions (if any)

No response

.NET Version

The command could not be loaded, possibly because: * You intended to execute a .NET application: The application ‘–version’ does not exist. * You intended to execute a .NET SDK command: No .NET SDKs were found. Download a .NET SDK: https://aka.ms/dotnet-download Learn about SDK resolution: https://aka.ms/dotnet/sdk-not-found

Anything else?

dotnet-sdk-6.0/jammy,now 6.0.400-1 amd64 [installed]

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 40
  • Comments: 30 (5 by maintainers)

Most upvoted comments

I have a fix !

  1. Run sudo apt remove --purge --autoremove *dotnet*

  2. create or modify /etc/apt/preferences and add (you’ll need sudo)

    Package: *net*
    Pin: origin packages.microsoft.com
    Pin-Priority: 1001
    

    Run man apt_preferences for more info about this config.

  3. Run sudo apt install dotnet-sdk-6.0

  4. Enjoy !


Output of cat /etc/*release:

DISTRIB_ID=LinuxMint
DISTRIB_RELEASE=21
DISTRIB_CODENAME=vanessa
DISTRIB_DESCRIPTION="Linux Mint 21 Vanessa"
NAME="Linux Mint"
VERSION="21 (Vanessa)"
ID=linuxmint
ID_LIKE="ubuntu debian"
PRETTY_NAME="Linux Mint 21"
VERSION_ID="21"
HOME_URL="https://www.linuxmint.com/"
SUPPORT_URL="https://forums.linuxmint.com/"
BUG_REPORT_URL="http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/"
PRIVACY_POLICY_URL="https://www.linuxmint.com/"
VERSION_CODENAME=vanessa
UBUNTU_CODENAME=jammy

Don’t use /etc/apt/preferences. Create a new file in /etc/apt/preferences.d instead!

sudo nano /etc/apt/preferences.d/dotnet

With content:

Package: dotnet*
Pin: origin packages.microsoft.com
Pin-Priority: 1001

and

sudo nano /etc/apt/preferences.d/aspnet

With content:

Package: aspnet*
Pin: origin packages.microsoft.com
Pin-Priority: 1001

EDIT: Or more easy with heredoc:

sudo sh -c "cat > /etc/apt/preferences.d/dotnet <<'EOF'
Package: dotnet*
Pin: origin packages.microsoft.com
Pin-Priority: 1001
EOF"
sudo sh -c "cat > /etc/apt/preferences.d/aspnet <<'EOF'
Package: aspnet*
Pin: origin packages.microsoft.com
Pin-Priority: 1001
EOF"

It’s not straightforward to fix.

For folks that don’t register the Microsoft feeds, there is no problem. It is the mixing and matching of the Ubuntu and Microsoft feeds that cause issues and require special handling.

Documented at https://learn.microsoft.com/en-us/dotnet/core/install/linux-package-mixup?pivots=os-linux-ubuntu#whats-going-on

How is this not a breaking change? A minor version update shouldn’t nuke a previously functioning installation! This breaks local dev, but it probably breaks a bunch of CI pipelines etc.

EDIT: https://github.com/dotnet/sdk/issues/27129#issuecomment-1214358108 is the correct fix at the moment.

Following the steps here: https://github.com/dotnet/core/issues/7699 will leave you with an outdated SDK and stuck with an old dependency of libunwind which can prevent other software installation / cause dependency conflicts.

Hello folks, please check https://github.com/dotnet/core/issues/7699 for more details about this.

I’ve had the same issues as well ever since I updated my .NET SDK to the latest version. I’m on Pop!_OS 22.04 (based on Ubuntu 22.04).

Why don’t you just fix this?

I updated the document to make it clear when you are intended to use of the “scenarios”.

https://github.com/dotnet/core/issues/7699

I have a fix !

  1. Run sudo apt remove --purge --autoremove *dotnet*

  2. create or modify /etc/apt/preferences and add (you’ll need sudo)

    Package: *net*
    Pin: origin packages.microsoft.com
    Pin-Priority: 1001
    

    Run man apt_preferences for more info about this config.

  3. Run sudo apt install dotnet-sdk-6.0

  4. Enjoy !

Output of cat /etc/*release:

DISTRIB_ID=LinuxMint
DISTRIB_RELEASE=21
DISTRIB_CODENAME=vanessa
DISTRIB_DESCRIPTION="Linux Mint 21 Vanessa"
NAME="Linux Mint"
VERSION="21 (Vanessa)"
ID=linuxmint
ID_LIKE="ubuntu debian"
PRETTY_NAME="Linux Mint 21"
VERSION_ID="21"
HOME_URL="https://www.linuxmint.com/"
SUPPORT_URL="https://forums.linuxmint.com/"
BUG_REPORT_URL="http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/"
PRIVACY_POLICY_URL="https://www.linuxmint.com/"
VERSION_CODENAME=vanessa
UBUNTU_CODENAME=jamm

My bad… I updated the comment!

Same issue here. Ubuntu 22.04.

$ dotnet --info

global.json file:
  Not found

Host:
  Version:      6.0.8
  Architecture: x64
  Commit:       55fb7ef977

.NET SDKs installed:
  No SDKs were found.

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.8 [/usr/lib/dotnet/dotnet6-6.0.108/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.8 [/usr/lib/dotnet/dotnet6-6.0.108/shared/Microsoft.NETCore.App]

Download .NET:
  https://aka.ms/dotnet-download

Learn about .NET Runtimes and SDKs:
  https://aka.ms/dotnet/runtimes-sdk-info

apt purge with a reinstall does not fix the issue.

Edit: I am using the dotnet-sdk-6.0 package, version 6.0.400-1, from the official Microsoft Debian repository:

$ cat /etc/apt/sources.list.d/microsoft-prod.list 
deb [arch=amd64,arm64,armhf] https://packages.microsoft.com/ubuntu/22.04/prod jammy main

It was working fine until I updated yesterday. I think I was on 6.0.300 before.

I encountered this problem after installing .net7 on ubuntu 22.04. I also needed the .net6 SDK and runtimes which were already installed, but after the .net7 installation, they did not show up.

.NET SDKs installed:
  7.0.101 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 7.0.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 7.0.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

a couple of uninstall/purge/clean/remove steps yielded the same result; thus, for a quick workaround, I basically moved .net6 related directories from /usr/lib/dotnet to /usr/share/dotnet, which the latter path is configured to work with dotnet cli.

after moving .net6 SDK and runtime folders under /usr/share/dotnet; they started to list, and no issues with build & run

.NET SDKs installed:
  6.0.404 [/usr/share/dotnet/sdk]
  7.0.101 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.11 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.11 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

This breaks my dev env on Linux machine. Rider just suddenly not working anymore. Although I fixed it temperarily by https://github.com/dotnet/sdk/issues/27129#issuecomment-1214358108 (Thanks!) It’s a very bad issue.

Thanks, Rich! I followed the instructions in “Mixed state scenario 1” and am back up and running. It’s nice to be able to install the SDK without an extra sources entry now.

hello folks, after I had updated, the issue appeared to me too. dotnet worked but when I tried to execute with build arg or other few except --verion it showed me the error. what helped me, open link provided by baronfel, and do two steps: ‘Use .NET 6 Package via PMC’ and ‘Scenario 1: Use native Jammy packages after installing a previous .NET release from PMC’