I am trying to install dotnet-sdk-3.0 on linux AMI 2 ec2 instance (c6g). I am new to linux so tried couple of commands but nothing seems working for me. I tried below.
sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
sudo yum install dotnet-sdk-3.1
sudo yum install dotnet-sdk-3.0
When tried above i am getting below error.
[ec2-user@ip-0-0-0-0 console]$ sudo yum install dotnet-sdk-3.0
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
amzn2-core | 3.7 kB 00:00
amzn2extra-docker | 3.0 kB 00:00
amzn2extra-nginx1.12 | 1.3 kB 00:00
packages-microsoft-com-prod | 3.0 kB 00:00
packages-microsoft-com-prod/primary_db | 288 kB 00:00
No package dotnet-sdk-3.0 available.
Error: Nothing to do
Then i tried
mkdir -p "$HOME/dotnet" && tar zxf dotnet-sdk-3.0.100-linux-x64.tar.gz -C "$HOME/dotnet"
export DOTNET_ROOT=$HOME/dotnet
export PATH=$PATH:$HOME/dotnet
After this tried the dotnet command but got the error. dotnet: command not found
Finally tried below:
mkdir -p $HOME/dotnet && tar zxf dotnet-sdk-3.1.302-linux-arm64.tar.gz -C $HOME/dotnet
export DOTNET_ROOT=$HOME/dotnet
export PATH=$PATH:$HOME/dotnet
dotnet
dotnet --list-sdk
when i run this, i got below error
[ec2-user@ip-0-0-0-0 home]$ dotnet --list-sdk
Process terminated. Couldn't find a valid ICU package installed on the system. Set the configuration flag System.Globalization.Invariant to true if you want to run with no globalization support.
at System.Environment.FailFast(System.String)
at System.Globalization.GlobalizationMode.GetGlobalizationInvariantMode()
at System.Globalization.GlobalizationMode..cctor()
at System.Globalization.CultureData.CreateCultureWithInvariantData()
at System.Globalization.CultureData.get_Invariant()
at System.Globalization.CultureInfo..cctor()
at System.String.ToLowerInvariant()
at Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment.GetArch()
at Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment..cctor()
at Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment.GetRuntimeIdentifier()
at Microsoft.DotNet.Cli.MulticoreJitProfilePathCalculator.CalculateProfileRootPath()
at Microsoft.DotNet.Cli.MulticoreJitActivator.StartCliProfileOptimization()
at Microsoft.DotNet.Cli.MulticoreJitActivator.TryActivateMulticoreJit()
at Microsoft.DotNet.Cli.Program.Main(System.String[])
Aborted
also tried to run the dotnet <dotnet-project.dll> and received this error.
Failed to load ▒r▒), error: /home/ec2-user/dotnet/shared/Microsoft.NETCore.App/3.0.0/libhostpolicy.so: cannot open shared object file: No such file or directory
An error occurred while loading required library libhostpolicy.so from [/home/ec2-user/dotnet/shared/Microsoft.NETCore.App/3.0.0]
[ec2-user@ip-0-0-0-0 console]$
I have followed the microsoft document as well.
https://learn.microsoft.com/en-us/dotnet/core/install/linux-centos
Nothing seems working for me. Can someone please help me here, i am stuck from last 2 days.
Thanks in advance.
PS: I am completely newbie to linux.
2
Answers
You are running this on arm64/aarch64. It’s a relatively new architecture. It’s also incompatible with the Intel 64-bit architecture (
x86_64
orx64
). So you need to watch out for that.Installing via RPM
Edit: So, this is just not going to work if you want to use RPM packages.
Quoting https://learn.microsoft.com/en-us/dotnet/core/install/linux-centos:
You are using
aarch64
/arm64
. You are not usingx64
, so this is not going to work.You need to use the tarball installation method.
Out of date suggestions:You are running Amazon Linux 2, right? As the URL here says, this is for CentOS 7. It may (or it may not) work on your Linux distribution. Anyway, try it out.
The error says that it can’t find this package. Maybe a package with this name doesn’t exist? Maybe you are using the wrong name? Try using
yum list
to find the correct name:It should show you a list of packages, including names like
dotnet-sdk-3.0.103
. You can install that package by name, then:If that doesn’t work, try another package name from
yum list
and try installing that.Installing manually
You are running an
aarch64
machine. You need to use thearm64
tarball, not thex64
tarball. Thex64
tarball is for an Intel processor. It will not work on an ARM processor.That’s surprising. Let me break down what this set of steps is doing:mkdir -p "$HOME/dotnet"
creates a directory nameddotnet
in your home directorytar xf ...
extracts the dotnet SDK tarball in thedotnet
directory you created in step 1export DOTNET_ROOT=$HOME/dotnet
defines an environment variableDOTNET_ROOT
. .NET Runtime needs it; I am a bit fuzzy myself on whyexport PATH=$PATH:$HOME/dotnet
adds the directory you installed the .NET SDK into to the environment variablePATH
.PATH
is a list of locations that the OS uses to search for a command that you enter. For example, when you typedotnet
in the command line it searches fordotnet
executable (thinkdotnet.exe
on Windows) in this list of directories.So let’s try and debug it one by one:
dotnet
exist in your main home directory (aka$HOME
)? Can youcd ~/dotnet
? Does that work?dotnet
in thedotnet
directory in your$HOME
? Doesls $HOME/dotnet/dotnet
work? What does it show you?echo $PATH
show you? Does it include that dotnet directory in the value?which dotnet
, does it find thedotnet
executable in your main$HOME
directory?Running the SDK
The error includes this phrase: Couldn’t find a valid ICU package installed on the system.
It really means that. You need to install the ICU package for your Linux distribution:
And then try running
dotnet --list-sdk
again.Error Running
dll
This is strange. It says it can’t find a file that should be part of the .NET Core installation.
What does
dotnet --list-runtimes
say? Does it show the 3.0.0 runtime installed? If not, that means your installation is messed up. You should probably install .NET Core 3.0 again. (Or better yet, install 3.1 because 3.0 has been end-of-life’d).Does the file
/home/ec2-user/dotnet/shared/Microsoft.NETCore.App/3.0.0/libhostpolicy.so
exist? If it doesn’t it’s the same problem as above: your installation is messed up.What does
file /home/ec2-user/dotnet/shared/Microsoft.NETCore.App/3.0.0/libhostpolicy.so
say? Is it anELF 64-bit LSB shared object
?The output is:
ELF 64-bit LSB shared object, x86-64
This is a
x86-64
file! In other words, you have (somehow) installed anlinux-x64
(Intel 64-bit architecture) runtime. Not too surprisingly, it doens’t work on the ARM 64 bit architecture. You need to delete this and re-install the SDK. I suggest just blowing away your current installation (rm -rf $HOME/dotnet
) and install thelinux-arm64
SDK again.I was able to get this to work on Amazon Linux 2 ARM64 with the following steps:
Amazon Linux 2 has version 50 available in the package manager, but dotnet looks for version 55 or later. When Amazon Linux updates this, this step won’t be necessary anymore and can be replaced withAmazon Linux 2 recently addedsudo yum install icu
.Install gcc and python3 because they’ll be needed for building
libicu
. It takes a few minutes to build the library.libicu60
to the package manager, so you can simply install it with yum: