I can't access dotnet after an update. Reinstalling dotnet and vscode didn't help.
On Ubuntu 22.04, running dotnet --info
produces the output:
A fatal error occurred. The folder [/usr/share/dotnet/host/fxr] does not exist
I can't access dotnet after an update. Reinstalling dotnet and vscode didn't help.
On Ubuntu 22.04, running dotnet --info
produces the output:
A fatal error occurred. The folder [/usr/share/dotnet/host/fxr] does not exist
When .NET (Core) was first released for Linux, it was not yet available in the official Ubuntu repo. So instead, many of us added the Microsoft APT repo in order to install it.
Now, the packages are part of the Ubuntu repo, and they are conflicting with the Microsoft packages. This error is a result of mixed packages.
So you need to pick which one you're going to use, and ensure they don't mix. Personally, I decided to stick with the Microsoft packages because I figured they'll be better kept up-to-date.
First, remove all existing packages to get to a clean state:
sudo apt remove dotnet* aspnetcore* netstandard*
Then, create a file in /etc/apt/preferences.d
(I named mine 99microsoft-dotnet.pref
, following the convention that files in such *.d
directories are typically prefixed with a 2-digit number so that they sort and load in a predictable order) with the following contents:
Package: *
Pin: origin "packages.microsoft.com"
Pin-Priority: 1001
Then, the regular update & install:
sudo apt update && sudo apt install -y dotnet-sdk-8.0
Note, the above example shows .NET 8; replace with another version if you prefer. .NET SDKs are installed side-by-side, so you can also install multiple versions.
If you would rather use the official Ubuntu packages, remove all the existing packages as above, but instead of creating the /etc/apt/preferences.d
entry, just delete the Microsoft repo:
sudo rm /etc/apt/sources.list.d/microsoft-prod.list
sudo apt update
sudo apt install dotnet-sdk-7.0
However, note that the Microsoft repo contains other packages such as PowerShell, SQL Server Command-Line Tools, etc., so removing it may not be desirable.
I'm sure it's possible to make the APT config more specific to just these packages, but this is working for me for now. Hopefully Microsoft and Ubuntu work together to fix this soon.
More info on the issue and various solutions is available here:
99microsoft-dotnet
file solves this issue? Thanks! –
Chokecherry dotnet
, aspnetcore
, netstandard
) should have a higher priority. More info on how to configure apt
priority is here: wiki.debian.org/AptConfiguration –
Kolomna /etc/apt/preferences.d
is *.pref
according to this askubuntu answer. Hence, I'd rename 99microsoft-dotnet
to 99microsoft-dotnet.pref
. –
Waikiki apt upgrade
with --allow-downgrades
that seems to keep me on the correct version. –
Luculent --allow-downgrades
, I'll try that if it happens again! –
Kolomna I had a same error and I did install .Net with microsoft packages. I think the problem is if you have had older .Net or mixing scenarios regarding Ubuntu package and .Net packages(f.x via Jammy or PMC). BTW, I solved my problem to stick with Ubuntu packages and did run this bash script :
# First, try to remove/uninstall older .Net, if any, then install .Net 6
echo "$(tput setaf 3)Installing .Net 6$(tput sgr0)"
sudo apt remove 'dotnet*'
sudo apt remove 'aspnetcore*'
sudo apt remove 'netstandard*'
sudo rm /etc/apt/sources.list.d/microsoft-prod.list
sudo rm /etc/apt/sources.list.d/microsoft-prod.list.save
sudo apt update
sudo apt install dotnet6
I've got this error message after:
sudo apt install dotnet-host
This solved it for me:
sudo apt install dotnet-sdk-6.0
dotnet
but it wasn't installed, I also ran apt install dotnet-host
and ran into this problem. I can confirm that using the suggested workaround (in my case, pkg remove dotnet-host; pkg install dotnet-sdk-7.0
) worked. –
Elliottellipse sudo su
insert you password and go to seccond point:
install dotnet-host-7.0
2.1) If you want to develope systems using .net
apt install dotnet-sdk-7.0
If you want to remove olders versions:
sudo apt remove 'dotnet*'
sudo apt remove 'aspnetcore*'
sudo apt remove 'netstandard*'
In case anyone encounters the same error right now (2023 July), I've tried a lot of the comments and blog posts, but this worked for me perfectly:
There is a part:
dotnet --version
A fatal error occurred. The folder [/usr/share/dotnet/host/fxr] does not exist
Great.
Since there, just follow along and it works :)
Not my solution, all respect to the author of this post:
In my case I had to remove /etc/apt/sources.list.d/mssql-release.list
which had been installed as part of some other work where I needed ODBC drivers. It says mssql, but that's the same source as the MS dotnet packages, causing the interference.
To stick with just the Ubuntu packages:
sudo rm -f /etc/apt/sources.list.d/mssql-release.list
sudo apt purge dotnet* aspnetcore* netstandard*
sudo apt update
sudo apt install dotnet-sdk-6.0
I had this error when I created a new VS Code Dev Container using Ubuntu Jammy and selecting the "dotnet CLI" feature. I ended up switching my Dev Container to use Focal and the problem went away.
In my case, i needed to do an "Upgrade" before an "Update".
sudo apt remove dotnet* aspnetcore* netstandard*
sudo apt upgrade
sudo apt update
sudo apt install dotnet-sdk-6.0
sudo apt remove dotnet-sdk* dotnet-host* dotnet* aspnetcore* netstandard*
sudo apt remove aspnetcore*
sudo apt remove netstandard*
sudo apt remove dotnet-host*
sudo apt purge dotnet-sdk* dotnet-host* dotnet* aspnetcore* netstandard*
sudo rm -f /etc/apt/sources.list.d/mssql-release.list
sudo rm /etc/apt/sources.list.d/microsoft-prod.list
sudo rm /etc/apt/sources.list.d/microsoft-prod.list.save
sudo apt update
Install by App Center: .Net Core SDK, Stable 8.0.101
there is no need for other installations!
(sudo snap install dotnet-sdk #Installed by App Center
sudo apt install dotnet-sdk-8.0 #Installed by App Center
sudo apt install dotnet-host-8.0 #Installed by dotnet-sdk-8.0)
dotnet workload update
source ~/.bashrc
dotnet sdk check
dotnet --info
dotnet --list-sdks
8.0.100 [/snap/dotnet-sdk/233/sdk]
dotnet --version
8.0.100
For those running into this problem on MacOS (installed via MacPorts): There seem to be three ports needed to actually run it:
sudo port install dotnet-cli
sudo port install dotnet-runtime-8
sudo port install dotnet-sdk-8
(Or maybe with differing version numbers) I had the same error message as in the original post after installing just dotnet-cli
, the second install of dotnet-runtime-8
changed the error-message and the third install of dotnet-sdk-8
made it finally work.
© 2022 - 2024 — McMap. All rights reserved.
apt
? Is it possible you have multiple instances of dotnet in your path? – Abernon