skip to Main Content

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


  1. 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 or x64). 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:

    Package manager installs are only supported on the x64 architecture. Other architectures, such as ARM, must manually install the .NET Core SDK or .NET Core Runtime. For more information, see the manually install section below.

    You are using aarch64/arm64. You are not using x64, so this is not going to work.

    You need to use the tarball installation method.

    Out of date suggestions:

    I am trying to install dotnet-sdk-3.0 on linux AMI 2 ec2 instance (c6g).

    sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
    

    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.

    $ sudo yum install dotnet-sdk-3.0
    No package dotnet-sdk-3.0 available.
    Error: Nothing to do
    

    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:

    sudo yum list 'dotnet-sdk*'
    

    It should show you a list of packages, including names like dotnet-sdk-3.0.103. You can install that package by name, then:

    sudo yum install dotnet-sdk-3.0.103
    

    If that doesn’t work, try another package name from yum list and try installing that.

    Installing manually

    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

    You are running an aarch64 machine. You need to use the arm64 tarball, not the x64 tarball. The x64 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:

    1. mkdir -p "$HOME/dotnet" creates a directory named dotnet in your home directory
    2. tar xf ... extracts the dotnet SDK tarball in the dotnet directory you created in step 1
    3. export DOTNET_ROOT=$HOME/dotnet defines an environment variable DOTNET_ROOT. .NET Runtime needs it; I am a bit fuzzy myself on why
    4. export PATH=$PATH:$HOME/dotnet adds the directory you installed the .NET SDK into to the environment variable PATH. PATH is a list of locations that the OS uses to search for a command that you enter. For example, when you type dotnet in the command line it searches for dotnet executable (think dotnet.exe on Windows) in this list of directories.

    So let’s try and debug it one by one:

    • Does the directory dotnet exist in your main home directory (aka $HOME)? Can you cd ~/dotnet? Does that work?
    • After you extract the tarball, do you see a file named dotnet in the dotnet directory in your $HOME? Does ls $HOME/dotnet/dotnet work? What does it show you?
    • What does echo $PATH show you? Does it include that dotnet directory in the value?
    • If you run which dotnet, does it find the dotnet executable in your main $HOME directory?

    Running the 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
    

    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:

    sudo yum install libicu
    

    And then try running dotnet --list-sdk again.

    Error Running dll

    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]
    

    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 an ELF 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 an linux-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 the linux-arm64 SDK again.

    Login or Signup to reply.
  2. I was able to get this to work on Amazon Linux 2 ARM64 with the following steps:

    1. Download and build a recent version of International Components for Unicode. 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 with sudo yum install icu.
      Install gcc and python3 because they’ll be needed for building libicu. It takes a few minutes to build the library.
      Amazon Linux 2 recently added libicu60 to the package manager, so you can simply install it with yum:
    sudo yum -y install libicu60
    
    1. Follow the instructions from Microsoft to install the dotnet sdk. Download the dotnet sdk from the Microsoft Website. You may need to download from this link to get the latest version, but the link below worked for me.
    cd ~
    wget https://download.visualstudio.microsoft.com/download/pr/5ee48114-19bf-4a28-89b6-37cab15ec3f2/f5d1f54ca93ceb8be7d8e37029c8e0f2/dotnet-sdk-3.1.302-linux-arm64.tar.gz
    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
    
    1. Test that it’s working
    [ec2-user@ip-172-31-69-243 ~]$ dotnet --list-sdks
    3.1.302 [/home/ec2-user/dotnet/sdk]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search