'Process terminated. Couldn't find a valid ICU package installed on the system in Asp.Net Core 3 - ubuntu

I am trying to run a Asp.Net Core 3 application in Ubuntu 19.10 thru terminal using dotnet run command but it does not seem to work. I get this error.

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.StringComparer..cctor()   
 at System.StringComparer.get_OrdinalIgnoreCase()   
 at Microsoft.Extensions.Configuration.ConfigurationProvider..ctor()   
 at Microsoft.Extensions.Configuration.EnvironmentVariables.EnvironmentVariablesConfigurationSource.Build(Microsoft.Extensions.Configuration.IConfigurationBuilder)
 at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()   
 at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder..ctor(Microsoft.Extensions.Hosting.IHostBuilder)
 at Microsoft.Extensions.Hosting.GenericHostWebHostBuilderExtensions.ConfigureWebHost(Microsoft.Extensions.Hosting.IHostBuilder, System.Action'1<Microsoft.AspNetCore.Hosting.IWebHostBuilder>)   
 at Microsoft.Extensions.Hosting.GenericHostBuilderExtensions.ConfigureWebHostDefaults(Microsoft.Extensions.Hosting.IHostBuilder, System.Action'1<Microsoft.AspNetCore.Hosting.IWebHostBuilder>)   
 at WebApplication.Program.CreateHostBuilder(System.String[])   
 at WebApplication.Program.Main(System.String[])

I installed the dotnet core sdk using the ubuntu store and after that I also installed Rider IDE.

The weird thing here is that when I run the app using Rider it runs fine, the only issue is using terminal dotnet core commands.

Does anybody know what might be the issue ?

The application is created using Rider. I don't think that this plays a role but just as a side fact.

I know there are also other ways to install dotnet core in ubuntu but since the sdk is available in the ubuntu story I thought it should work out of the box and of course its an easier choice.

Also tried this one but does not seem to work for me. Still the same issue happens after running the commands.



Solution 1:[1]

The alternative solution as described in Microsoft documentation is to set environment variable before running your app

export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1

Solution 2:[2]

If you want to run with no globalization support, you need to get "System.Globalization.Invariant": true into your published output AppName.runtimeconfig.json file as shown in the example below:

{
  "runtimeOptions": {
    "tfm": "netcoreapp3.0",
    "configProperties": {
      "System.GC.Server": true,
      "System.Globalization.Invariant": true
    }
  }
}

You can add it manually every time you deploy by adding or updating the AppName.runtimeconfig.json file. Better yet, add it once to a runtimeconfig.template.json file like this:

{
  "configProperties": {
    "System.Globalization.Invariant": true
  }
}

Make sure that runtimeconfig.template.json is included in build/publish.

Solution 3:[3]

It seem the package libicu63 will provide the ico support for dotnet on Linux, at least on Debian'ish distros.

Update:

And it seems it's "missing" when doing a small installing of Debian (i.e. deselect all applications/system-options in the installation program, except for SSH server)

Solution 4:[4]

Yes. When installing Github action in Debian. It is also required.

As the response from MrCalvin, sudo apt-get update && sudo apt-get install -qqq libicu63 resolve my issue.

Solution 5:[5]

The trick around it on Ubuntu 20.04 based on this thread https://github.com/dotnet/core/issues/2186#issuecomment-671105420

$export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1

Solution 6:[6]

In my case, I followed the Windows documentation to install SDK dependencies and Runtime, watch out for the corresponding version to each Linux distribution to avoid compatibility issues.

Solution 7:[7]

edit your .bashrc file by adding the following line, e.g.:

nano ~/.bashrc

add

export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1

Ctrl+o, Ctrl+x

restart terminal and run pwsh again

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 nt86
Solution 2 Wai Ha Lee
Solution 3
Solution 4 Alpha
Solution 5 Daniel Okello
Solution 6 Barnum Castillo
Solution 7 userko