dotnet stops with 'the folder host/fxr does not exist' on Ubuntu
A fatal error occurred. The folder [/usr/share/dotnet/host/fxr] does not existShort answer
This error nearly always means .NET packages came from two different package feeds, usually Ubuntu's own and Microsoft's, and each put files in a different place. Remove every dotnet package, keep one feed only (pin the other one off), then reinstall from that feed.
Fix it fast
1Find out which cause you have
List which .NET packages are installed and which feed each one came from. If you see the same package family offered by both Ubuntu and packages.microsoft.com, you have found the cause.
dotnet --info apt-cache policy '?name(dotnet.*)' ls -d /usr/lib/dotnet /usr/lib64/dotnet /usr/share/dotnet 2>/dev/null2Match what you see, then jump to its fix
- 1
Both /usr/share/dotnet and /usr/lib64/dotnet exist, and apt-cache policy lists dotnet packages from packages.microsoft.com next to ones from an Ubuntu archiveUbuntu's .NET packages and the Microsoft feed are both installedFix - 2
The error appears after you added the Microsoft feed or the Ubuntu .NET backports repository to get a version that is not in the default Ubuntu archiveYou need a .NET version Ubuntu does not ship, and both feeds still answerFix - 3
dotnet --info points at a folder you extracted yourself, and the error names a different folder such as /usr/share/dotnetThe dotnet on your PATH is a manual install that was never set up as oneFix
- 1
What does the error look like?
A fatal error occurred. The folder [/usr/share/dotnet/host/fxr] does not existA fatal error occurred. The required library libhostfxr.so could not be found.A fatal error occurred, the folder [/usr/share/dotnet/host/fxr] does not contain any version-numbered child folders
Cause 1 of 3
Ubuntu's .NET packages and the Microsoft feed are both installed
1Check
Microsoft documents this as a package mix-up: two repositories supply .NET, put files at different paths and are built differently. If you only wanted Ubuntu's packages, the Microsoft feed is the one to switch off.
apt-cache policy '?name(dotnet.*)' | grep -E 'packages.microsoft.com|ubuntu'
ls /etc/apt/sources.list.d/ | grep -i microsoft2Fix
Remove all .NET packages, then stop the Microsoft feed from supplying them. If you use that feed for other software (PowerShell, for example), pin only the .NET names off it. If you do not, delete the feed file. Then install again from Ubuntu.
sudo apt remove 'dotnet*' 'aspnet*' 'netstandard*'
# Option A: you need the Microsoft feed for other packages.
# Create /etc/apt/preferences (if missing) and add:
# Package: dotnet* aspnet* netstandard*
# Pin: origin "packages.microsoft.com"
# Pin-Priority: -10
# Option B: you do not need the Microsoft feed at all.
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
sudo apt update
sudo apt-get install -y dotnet-sdk-8.03Verify
The SDK is listed and a new project builds.
dotnet --list-sdks
dotnet new console -o /tmp/fxr-check && dotnet run --project /tmp/fxr-checkConfirmed by learn.microsoft.com
Cause 2 of 3
You need a .NET version Ubuntu does not ship, and both feeds still answer
1Check
Microsoft's rule is to use one source per machine. Here the extra version comes from a second source, so the distribution's own .NET packages must be switched off, not the other way round. On Ubuntu 22.04 and 24.04, the backports repository is the documented way to get .NET 9 and 10 where they are not in the default archive.
apt-cache policy '?name(dotnet.*)' | grep 'ppa.launchpadcontent.net/dotnet/backports' | sort -u
sudo apt-get install -y dotnet-sdk-9.0 --dry-run | head2Fix
Remove all .NET packages. Either pin the other source's .NET packages to -10 in /etc/apt/preferences (one stanza per origin, for example archive.ubuntu.com and security.ubuntu.com), or add the backports repository and install from it alone, then reinstall.
sudo apt remove 'dotnet*' 'aspnet*' 'netstandard*'
sudo add-apt-repository ppa:dotnet/backports
sudo apt-get update && sudo apt-get install -y dotnet-sdk-9.03Verify
Only one origin remains for the dotnet packages and the host files are found.
apt-cache policy dotnet-sdk-9.0
dotnet --infoConfirmed by learn.microsoft.com
Cause 3 of 3
The dotnet on your PATH is a manual install that was never set up as one
1Check
A tarball or install-script copy does not live under /usr/share/dotnet. Its folder must be in DOTNET_ROOT and on PATH, otherwise the launcher looks in the default location and finds nothing.
echo "$DOTNET_ROOT"
which -a dotnet2Fix
Point DOTNET_ROOT at the folder you installed into and put it on PATH, in your shell profile so it survives a new terminal.
export DOTNET_ROOT=$HOME/.dotnet
export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools3Verify
A new terminal reports the SDK from that folder.
dotnet --list-sdksConfirmed by learn.microsoft.com
How do I stop it coming back?
- Install .NET from one source per machine, and write down which one it is.
- On Ubuntu 24.04, do not add the Microsoft feed just for .NET: Microsoft says its repository no longer contains .NET packages for that release.
- Run dotnet --list-sdks and dotnet --list-runtimes after any package change, before you build.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Servers
dotnet says it cannot find any installed .NET SDKs (in Docker or on a server)
A compatible .NET SDK was not found
The dotnet command found a runtime but no SDK that fits.
3 causes, each with a fixServers
AuthenticationException: the remote certificate is invalid in .NET
System.Security.Authentication.AuthenticationException: The remote certificate is invalid because of errors in the certificate chain: UntrustedRoot, NotValidTime
The error lists the chain status flags .NET found.
3 causes, each with a fixServers
Playwright for .NET cannot find the browser inside a Docker container
Microsoft.Playwright.PlaywrightException: Executable doesn't exist
The container has no browser build that matches the Playwright NuGet package your code uses.
3 causes, each with a fixServers
A .NET app on Linux cannot trust the SQL Server certificate
SSL Provider: The certificate chain was issued by an authority that is not trusted.
Microsoft.Data.SqlClient 4.0 and later encrypts by default and validates the server certificate.
3 causes, each with a fixServers
dnf cannot install MySQL on Amazon Linux 2023
dnf cannot find a mysql-server package on Amazon Linux 2023
Amazon Linux 2023 documents MariaDB, not MySQL, as its database server, with packages named mariadb105 and mariadb105-server.
3 causes, each with a fixServers
Ansible hangs, then times out waiting for the sudo prompt
a playbook using become seems to hang
Ansible ran sudo on the target and never saw the answer it expected.
3 causes, each with a fix