Couldn’t Find a Valid ICU Package

As I ran my .NET 5 application on Linux, I was greeted with the following error:

Exception
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.Globalization.CultureInfo.get_CurrentCulture()
at System.Globalization.NumberFormatInfo.get_CurrentInfo()
...
Aborted (core dumped)

Underlying cause was my ancient Red Hat installation missing localization support and the easy way to deal with it is was to simply set DOTNET_SYSTEM_GLOBALIZATION_INVARIANT environment variable. On command line that would look something like this:

Terminal
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1 ./myprogram

However, if we really don't need globalization support, setting it directly in .csproj might be better:

.csproj
<PropertyGroup>
<InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>

One thought to “Couldn’t Find a Valid ICU Package”

  1. If you are using Ubuntu 20.04, this might help out

    $export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1

Leave a Reply

Your email address will not be published. Required fields are marked *