Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 361
Rajmond Burgaj Avatar asked Nov 30 '19 20:11

Rajmond Burgaj


2 Answers

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

export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
like image 76
nt86 Avatar answered Sep 30 '22 19:09

nt86


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.

like image 42
Justin Avatar answered Sep 30 '22 19:09

Justin