question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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]

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:38
  • Comments:29 (5 by maintainers)

github_iconTop GitHub Comments

157reactions
olfekcommented, Aug 14, 2022

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
7reactions
kitingChriscommented, Feb 17, 2023

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"
Read more comments on GitHub >

github_iconTop Results From Across the Web

dotnet sdk is installed but not recognized - Linux Ubuntu ...
I had the same problem, and here's what I did to resolve it. Removed all .NET packages sudo apt remove 'dotnet*' sudo apt...
Read more >
Install the .NET SDK or the .NET Runtime on Ubuntu
I'm using an Arm-based CPU. I'm using Ubuntu 22.04, 22.10, or 23.04, and I only need .NET 6.0 or .NET 7.0. Install ......
Read more >
Why don't any of these methods work for installing .Net ...
I tried various removing and rebooting and many options but could never get the SDK installed properly.
Read more >
SDK is not found when dotnet6 package is installed on ...
To fix this, I uninstalled dotnet-sdk from apt and followed the steps to do it manually. Upvote 3
Read more >
Unable to locate the .NET SDK: The Reasons - Hamid Mosalla
Try running dotnet --list-sdks command to see if it lists the sdk. The .Net Sdk Is Installed But it Has Wrong System Type....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found