Open richlander opened 2 years ago
Ah,yeah. Removing the microsoft-prod deb source and updating helped.
sudo apt remove dotnet\* sudo rm /etc/apt/sources.iist.d/microsoft-prod.list sudo apt update sudo apt install -y dotnet6
However, I may have a similar issue on Fedora next...
Tried the steps but to no avail. Ubuntu 22.04
$ dn --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
I resolve the same problem by installing runtimes first then SDK. I run "sudo apt install aspnetcore-runtime-6.0" first, then run "sudo apt install dotnet6".
hey that does not worked for me on the first try because i copied the commands and "sources.iist.d" were typical wrong word .try "source.list.d" . it should wotk .
I tried it on ubunutu 22.04 and that worked
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
Quite painful, thanks for the guidance on getting up and running.
One extra step I had to do in order to run dotnet as a normal user (I'm not sure whether this is good practice from a security perspective):
cd /usr/lib
sudo chmod +x dotnet
Which feed is more up-to-date: PMC or Ubuntu?
@richlander
The instructions should be updated to use single quotes when using the *
in shell commands. For example:
sudo apt remove 'dotnet*'
Otherwise, if the current directory has any files or folders match the glob, the shell will expand them. For example, if the user had a file named dotnet_wish_list.txt
in their current directory, the command sudo apt remove dotnet*
would expand to sudo apt remove dotnet_wish_list.txt
, which will not have the intended effect.
My dotnet application runs when started as user but fails as root with sudo command claiming that .NET is not installed. Tried removing/reinstalling but nothing works
fish@host:~/SimpleApp$ sudo ./SimpleApp
You must install .NET to run this application.
App: /home/fish/SimpleApp/SimpleApp
Architecture: x64
App host version: 6.0.10
.NET location: Not found
If I run the same without sudo everything works.
fish@host:~$ dotnet --info
.NET SDK (reflecting any global.json):
Version: 6.0.111
Commit: b3bb659a9d
Runtime Environment:
OS Name: ubuntu
OS Version: 22.04
OS Platform: Linux
RID: ubuntu.22.04-x64
Base Path: /usr/lib/dotnet/sdk/6.0.111/
global.json file:
Not found
Host:
Version: 6.0.11
Architecture: x64
Commit: 943474ca16
.NET SDKs installed:
6.0.111 [/usr/lib/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.11 [/usr/lib/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.11 [/usr/lib/dotnet/shared/Microsoft.NETCore.App]
Download .NET:
https://aka.ms/dotnet-download
Learn about .NET Runtimes and SDKs:
https://aka.ms/dotnet/runtimes-sdk-info
Hi @d-kar!
Do you mean that if you do fish@host:~/SimpleApp$ ./SimpleApp
it is OK?
For the .111 in Ubuntu we're facing some issues with the DOTNET_ROOT variable and the install_location files, affecting AppHost (https://github.com/dotnet/runtime/issues/79237 ... you can find here some workarounds in the meantime). We already have a fix that will be released next week on .112.
Sorry for the inconvenience.
Do you mean that if you do
fish@host:~/SimpleApp$ ./SimpleApp
it is OK?
Yes, running without sudo is OK. When I check environment var DOTNET_ROOT it is set, but when I change to root user it dissapears. After that when I change back to my user account environment variable is dissapeared all together. I'm not too familiar with Linux so not sure what's going on here.
fish@host:~/SimpleApp$ echo $DOTNET_ROOT
/usr/lib/dotnet
fish@host:~/SimpleApp$ sudo echo $DOTNET_ROOT
/usr/lib/dotnet
fish@host:~/SimpleApp$ sudo su
root@host/home/fish/SimpleApp# echo $DOTNET_ROOT
root@host/home/fish/SimpleApp# su fish
fish@host:~/SimpleApp$ echo $DOTNET_ROOT
I use my app as a systemd service, so setting environment variable in .service file manually as a workaround works for me.
fish@host:~/SimpleApp$ echo $DOTNET_ROOT /usr/lib/dotnet fish@host:~/SimpleApp$ sudo echo $DOTNET_ROOT /usr/lib/dotnet fish@host:~/SimpleApp$ sudo su root@host/home/fish/SimpleApp# echo $DOTNET_ROOT root@host/home/fish/SimpleApp# su fish fish@host:~/SimpleApp$ echo $DOTNET_ROOT
I use my app as a systemd service, so setting environment variable in .service file manually as a workaround works for me.
It's weird that your $DOTNET_ROOT points to /usr/lib/donet
It looks empty for
osanhaji@5CD2068Y53:~ $ ls /usr/lib/dotnet/
packs
osanhaji@5CD2068Y53:~ $ ls /usr/lib/dotnet/packs/
NETStandard.Library.Ref
I have set it to:
osanhaji@5CD2068Y53:~ $ echo $DOTNET_ROOT
/usr/share/dotnet/
osanhaji@5CD2068Y53:~ $ ls $DOTNET_ROOT
dotnet host LICENSE.txt packs sdk sdk-manifests shared templates ThirdPartyNotices.txt
It looks like it works also when $DOTNET_ROOT is unset
Although I managed to install with PMC packages I am having trouble running tools.
dotnet ef returns You must install .NET to run this application.
App: /home/xxxx/.dotnet/tools/dotnet-ef Architecture: x64 App host version: 6.0.13 .NET location: Not found
Learn about runtime installation: https://aka.ms/dotnet/app-launch-failed
Download the .NET runtime: https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=ubuntu.22.04-x64&apphost_version=6.0.13
dotnet info `.NET SDK (reflecting any global.json): Version: 6.0.405 Commit: 27ab36058b
Runtime Environment: OS Name: ubuntu OS Version: 22.04 OS Platform: Linux RID: ubuntu.22.04-x64 Base Path: /usr/share/dotnet/sdk/6.0.405/
Host: Version: 7.0.2 Architecture: x64 Commit: d037e070eb
.NET SDKs installed: 6.0.405 [/usr/share/dotnet/sdk]
.NET runtimes installed: Microsoft.AspNetCore.App 6.0.13 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.13 [/usr/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.2 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Other architectures found: None
Environment variables: DOTNET_ROOT [/usr/lib/dotnet]
global.json file: Not found
Learn more: https://aka.ms/dotnet/info
Download .NET: https://aka.ms/dotnet/download `
I hit a bug in the Jammy versions of the SDKs that were fixed in newer version, so switched over to PMC following the above guide, updated and all was fine (also nice to get .net 7 option).
I'm wondering if it's the case that as a developer, all roads lead to needing the PMC versions of SDKs? In which case does it make more sense to only publish the runtimes on Ubuntu feeds? So end-users can get the runtime OOTB without much fuss, and developers can read the manual on how to install the SDK if they want it?
Although I managed to install with PMC packages I am having trouble running tools.
dotnet ef returns You must install .NET to run this application.
App: /home/xxxx/.dotnet/tools/dotnet-ef Architecture: x64 App host version: 6.0.13 .NET location: Not found
Learn about runtime installation: https://aka.ms/dotnet/app-launch-failed
Download the .NET runtime: https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=ubuntu.22.04-x64&apphost_version=6.0.13
dotnet info `.NET SDK (reflecting any global.json): Version: 6.0.405 Commit: 27ab36058b
Runtime Environment: OS Name: ubuntu OS Version: 22.04 OS Platform: Linux RID: ubuntu.22.04-x64 Base Path: /usr/share/dotnet/sdk/6.0.405/
Host: Version: 7.0.2 Architecture: x64 Commit: d037e070eb
.NET SDKs installed: 6.0.405 [/usr/share/dotnet/sdk]
.NET runtimes installed: Microsoft.AspNetCore.App 6.0.13 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.13 [/usr/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.2 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Other architectures found: None
Environment variables: DOTNET_ROOT [/usr/lib/dotnet]
global.json file: Not found
Learn more: https://aka.ms/dotnet/info
Download .NET: https://aka.ms/dotnet/download `
I had the same issue, I think maybe there's different behaviours and file locations between the Ubuntu debs and the PMC debs (i.e. PWC isn't correctly setting the path, or the location is wrong - one or the other)
Your runtime location (like mine) is "/usr/share/dotnet"
But when I checked on my machine DOTNET_ROOT (environment variable) was set as "/usr/lib/dotnet" and so it was in the content of "/etc/profile.d/dotnet.sh" and "/etc/dotnet/install_location"
I updated it to "/usr/share/dotnet" in all 3 locations and it's fixed - you might need to log out and back in again to see the change.
.NET SDK 7.0 on Ubuntu 22.10, setting DOTNET_ROOT
to /usr/share/dotnet
did not solve the issue for me, ended up copying everything from /usr/share/dotnet
to /usr/lib/dotnet
and now it's working fine.
I tried it on ubunutu 22.04 and that worked
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
that did it for me. Thanks!!
@richlander better use /etc/apt/preferences.d/dotnet
instead of /etc/apt/preferences
;)
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"
@richlander better use
/etc/apt/preferences.d/dotnet
instead of/etc/apt/preferences
;)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"
I'm trying to install dotnet 6 and 7 (sudo apt install dotnet-sdk-6.0 dotnet-sdk-7.0
). That works for me.
Been struggling for hours with this. Soooo frustrating - Should be simple. I am new to Linux.
Latest error : A fatal error occurred. The folder [/usr/share/dotnet/host/fxr] does not exist ( dotnet --info)
When I run dotnet --list-runtimes, I only see 7.0.3. It seems the 6 & 7 sdks are there but only the 7 runtime. I have tried to install the ver 6 runtime many many times.
So, more errors when I try and run a .net 6 project:
Framework: 'Microsoft.NETCore.App', version '6.0.0' (x64) .NET location: /usr/share/dotnet/ The following frameworks were found: 7.0.3 at [/usr/share/dotnet/shared/Microsoft.NETCore.App] Learn about framework resolution: https://aka.ms/dotnet/app-launch-failed To install missing framework, download: https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=6.0.0&arch=x64&rid=ubuntu.22.04-x64 . Please check the diagnostic logs for more information.
I have tried to install .net 6 using all scenarios - nothing works. So... back to a full uninstall of everything .net.
What a mess
There seems to be an issue in the ubuntu repos.
This command will create a setting that let apt prefer the microsoft packages over the ones from ubuntu.
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"
sudo apt-get remove --purge dotnet-*
And then reinstall.
Not a dotnet dev myself but supporting collegues that do. With Rider or vscode as IDE.
Didn't heard something not working but we are yet starting to migrate applications to .net 7.0
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"
I needed to add another clause for netstandard*
because netstandard-targeting-pack-2.1
was being installed as a dependency of dotnet-sdk-6.0
and was otherwise coming from the Ubuntu repos.
I have the same problem:
matt@MattPc:~/Matt/linux$ apt list -a dotnet-sdk-6.0
Listing... Done
dotnet-sdk-6.0/jammy,now 6.0.408-1 amd64 [installed]
dotnet-sdk-6.0/jammy 6.0.407-1 amd64
...
But:
matt@MattPc:~/Matt/linux$ dotnet --info
global.json file:
/mnt/c/Programming/Git/Matt/linux/global.json
Host:
Version: 6.0.16
Architecture: x64
Commit: 1e620a42e7
.NET SDKs installed:
No SDKs were found.
.NET runtimes installed:
Microsoft.NETCore.App 6.0.16 [/usr/lib/dotnet/shared/Microsoft.NETCore.App]
I was able to make it work with SDK 6.0.16 but I need the SDK 6.0.408 for a project.
I also try the script provide by Microsolf to install dotnet:
matt@MattPc:~/Matt/linux$ ./dotnet-install.sh
dotnet-install: .NET Core SDK with version '6.0.408' is already installed.
But still desn't detect when I run dotnet --info
.
What I did to Installing .NET 7 on Ubuntu 22.04 (Jammy)
# Purge old packages
sudo apt-get remove 'dotnet.*'
sudo apt-get remove 'aspnet.*'
# Get Ubuntu version
declare repo_version=$(if command -v lsb_release &> /dev/null; then lsb_release -r -s; else grep -oP '(?<=^VERSION_ID=).+' /etc/os-release | tr -d '"'; fi)
# Download Microsoft signing key and repository
wget https://packages.microsoft.com/config/ubuntu/$repo_version/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
# Install Microsoft signing key and repository
sudo dpkg -i packages-microsoft-prod.deb
# Clean up
rm packages-microsoft-prod.deb
# Update packages
sudo apt update
Then followed @kitingChris suggestion
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"
sudo apt install dotnet-sdk-7.0
That worked for me - everything else did not.
I followed all the steps, still couldn't get anything back from dotnet --list-sdks
. Then I read somewhere that I also had to uninstall dotnet-host
and I reran the steps from here an now I'm getting this error:
A fatal error occurred. The folder [/usr/share/dotnet/host/fxr] does not exist
Googling this leads me to many other suggested solutions yet, of which none has worked yet.
Man, I've been trying to upgrade from .NET 6 to .NET 7 on Ubuntu 22.04 for the last 3 hours now and not only does it not work, .NET is now completely broken and I'm unable to get it back into a working state again. What an abysmal experience.
Ok if someone else comes here and thinks that .NET just doesn't seem to install on Ubuntu 22.04 then there's hope. This is the only solution that worked for me:
First run this:
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin -c 7.0.2xx
Then add this to your .bashrc
:
export DOTNET_ROOT=$HOME/.dotnet
export PATH=$PATH:$HOME/.dotnet:$HOME/.dotnet/tools
@dustinmoris are you registering Microsoft package feed or rely on native Ubuntu package feeds? It seems that you do want to install 7.0.2xx feature band - solution for this scenario is provided in Mixed-state scenario 2
section of the first comment in this GitHub issue.
.NET 6 and 7 are provided in native Ubuntu feeds. The following page describes steps to install either .NET version on Ubuntu 22.04: https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu-2204 On that page, it is called out that only one package feed should be registered at the time to avoid issues you have hit.
Ubuntu 22.04, .NET 6.0 - was originally set up using PMC, with the APT preferences file as described in this issue:
# cat /etc/apt/preferences.d/microsoft
Package: *
Pin: origin "packages.microsoft.com"
Pin-Priority: 1001
All seemed to work, but after last last night's unattended upgrade of the .NET packages we get the dreaded
A fatal error occurred. The folder [/usr/share/dotnet/host/fxr] does not exist
So it seems that it somehow ended in the "mixed scenario", even though we had the APT preferences file - and it seems to have been effective on other machines during previous upgrades!
/var/log/apt/term.log contains:
Log started: 2023-10-26 06:25:59
...
(Reading database ... 120909 files and directories currently installed.)
Preparing to unpack .../dotnet-hostfxr-6.0_6.0.124-0ubuntu1~22.04.1_amd64.deb ...
Unpacking dotnet-hostfxr-6.0 (6.0.124-0ubuntu1~22.04.1) over (6.0.23-1) ...
Setting up dotnet-hostfxr-6.0 (6.0.124-0ubuntu1~22.04.1) ...
Log ended: 2023-10-26 06:26:00
Edit: The problem was probably our unattended upgrades config, which had this:
Unattended-Upgrade::Allowed-Origins {
"${distro_id}:${distro_codename}-updates"; // Allow non-security updates
};
So we allowed unattended upgrades from the Ubuntu APT source, but not from the MS one. The intention was to not upgrade .NET automatically (because that often breaks a running application!) so we've now added this:
Unattended-Upgrade::Package-Blacklist
{
"dotnet.*";
"aspnetcore.*";
};
Hopefully that's effective, but we won't know for sure until the next update of .NET is released.
All seemed to work, but after last last night's unattended upgrade of the .NET packages we get the dreaded ... So it seems that it somehow ended in the "mixed scenario", even though we had the APT preferences file - and it seems to have been effective on other machines during previous upgrades!
For those that wish to have unattended upgrades of dotnet, how about following https://askubuntu.com/a/1435868 and adding
Unattended-Upgrade::Allowed-Origins {
...
"microsoft-ubuntu-${distro_codename}-prod ${distro_codename}:${distro_codename}";
};
Ok if someone else comes here and thinks that .NET just doesn't seem to install on Ubuntu 22.04 then there's hope. This is the only solution that worked for me:
@dustinmoris I hope no one tries to follow/read your comment, because it is very misplaced. This github issue is about Ubuntu packages of .NET x.y.z (which means, packages provided by the Ubuntu distribution, so that you can install directly with the native package manager tool apt
without external scripts or external sources).
This issue still hasn't been fixed.
This github issue is not a bug.
And .net 9 is in preview...
See the title of this issue, it's about .NET6. If you have issues with .NET9 open a new github issue?
What issue? what tickets? sigh
FYI on our plan for Ubuntu 24.04 packages
After a recent machine rebuild, upgrading to Linux Mint 22.0 (equivalent to Ubuntu 24.04) I have the dotnet sdk 8.0 running happily. I now need to service an older application running on DotNet 6. I've been through your instructions and am left with:-
sudo apt install dotnet-sdk-6.0 Reading package lists... Done Building dependency tree... Done Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation:
The following packages have unmet dependencies. dotnet-runtime-deps-6.0 : Depends: libicu but it is not installable or libicu72 but it is not installable or libicu71 but it is not installable or libicu70 but it is not installable or libicu69 but it is not installable or libicu68 but it is not installable or libicu67 but it is not installable or libicu66 but it is not installable or libicu65 but it is not installable or libicu63 but it is not installable or libicu60 but it is not installable or libicu57 but it is not installable or libicu55 but it is not installable or libicu52 but it is not installable E: Unable to correct problems, you have held broken packages.
What do you suggest?
Installing .NET 6 on Ubuntu 22.04 (Jammy)
We announced support for .NET 6 on Ubuntu 22.04 with our May 2022 Updates. At that time, the supported installation methods were manual installation via a tarball or a
.deb
package via packages.microsoft.com (PMC). .NET 6 is now available natively via Jammy feeds, which can cause conflicts with PMC feeds. You need to apply the following guidance to install .NET 6 reliably and correctly on Ubuntu 22.04+.More information will be shared shortly on .NET 6 being available natively in the
jammy-updates
feed. In general, we recommend that you use the native packages from this feed since it is much easier and simpler.You can use one of the following scenarios:
Related:
Clean machine scenario 1: Use .NET 6 Package via Jammy feed
The easiest approach is to use the .NET 6 package available in Jammy feeds. In this scenario, just install
dotnet6
and don't register the PMC feed.You can do that via the following commands:
You can see this demonstrated with Docker:
Note: This build of .NET 6 is for the
6.0.1xx
band.6.0.4xx
builds are available via PMC. That difference matters most to Windows users. Both builds are supported.Clean machine scenario 2: Use .NET 6 Package via PMC
You can install .NET 6 on Ubuntu 22.04 from
packages.microsoft.com
using the following steps:Configure apt preferences, to prioritize PMC repository, by creating the following file:
/etc/apt/preferences
To create the file:
with contents:
Update your APT information:
sudo apt update
Install .NET SDK 6.0:
sudo apt install dotnet-sdk-6.0
Mixed state scenario 1: Use native Jammy packages after installing a previous .NET release from PMC
You may want to switch to using the .NET 6 package available in Jammy after installing .NET 6 from PMC.
Do the following:
sudo apt remove --purge dotnet*
sudo apt remove --purge aspnetcore*
sudo rm /etc/apt/sources.list.d/microsoft-prod.list
sudo apt update
sudo apt install dotnet-sdk-6.0
Mixed state scenario 2: Use PMC packages after installing native Jammy packages
You may want to switch to using
packages.microsoft.com
packages after installing native packages, potentially because you want to use6.0.4xx
builds.Do the following:
sudo apt remove --purge dotnet*
sudo apt remove --purge aspnetcore*
sudo apt install dotnet-sdk-6.0
How to identify which packages you'd installed
We'll install .NET 6 with both feeds, from a clean state, and then point the various ways you can identify which feed you installed the package from.
First, let's install the native Jammy packages using the "Clean machine scenario 1" guidance.
Notice that we've installed .NET SDK
6.0.108
, installed to/usr/lib/dotnet/
, and that thedotnet6
package is being installed fromhttp://archive.ubuntu.com/ubuntu jammy-updates/universe
. That's expected for the native packages.Let's try the same thing with PMC, but with the "Clean machine scenario 2" guidance.
Notice that we've installed .NET SDK
6.0.400
, installed to/usr/share/dotnet/
, and that thedotnet6
package is being installed fromhttps://packages.microsoft.com/ubuntu/22.04/prod jammy/main
. That's expected for PMC packages.We can also tell if the Microsoft PMC feed is registered:
If you are using native packages, that file won't and shouldn't be present.