Open LucHeart opened 1 year ago
Ran into the same issue. I had found the csproj flag but was missing the dockerfile change so that was helpful to find @LucHeart
Pretty much the same exception stack here:
fail: WardenBot.Discord.BackgroundServices.DiscordBackgroundService[0]
[Gateway] Error handling Dispatch (GUILD_AVAILABLE)
System.Globalization.CultureNotFoundException: Only the invariant culture is supported in globalization-invariant mode. See https://aka.ms/GlobalizationInvariantMode for more information. (Parameter 'name')
en-US is an invalid culture identifier.
at System.Globalization.CultureInfo..ctor(String name, Boolean useUserOverride)
at Discord.WebSocket.SocketGuild.Update(ClientState state, Guild model)
at Discord.WebSocket.SocketGuild.Update(ClientState state, ExtendedGuild model)
at Discord.WebSocket.DiscordSocketClient.ProcessMessageAsync(GatewayOpCode opCode, Nullable`1 seq, String type, Object payload)
+1 here
if you have an application with <InvariantGlobalization>true</InvariantGlobalization>
you can not use this library. Should be fixed asap, since some of the "dotnet new" templates come with this mode enabled by default!
Another way to reproduce issues related to this is to use dotnet's official chiseled Docker images. Similar to Alpine docker images, these chiseled images also exclude ICU data.
When I tried using Discord.NET with mcr.microsoft.com/dotnet/runtime:8.0-jammy-chiseled
, I ran into stack traces that match #2795. Switching to mcr.microsoft.com/dotnet/runtime:8.0-jammy-chiseled-extra
fixed those exceptions.
Discord.NET version
3.10.0
.NET version
7
Docker base image
mcr.microsoft.com/dotnet/runtime:7.0-alpine
Dockerfile to rep
csproj to rep
Background information
We were trying to just run a empty bot on a alpine dotnet7 runtime base image in docker. However we were immediately greeted with the error:
We then figured out that Discord.NET requires en-US as a culture. So the fix was simple: Add
<InvariantGlobalization>false</InvariantGlobalization>
to your csproj and addRUN apk add --no-cache icu-libs
to your dockerfile. That then fixed the issue we had so far, however I was questioning why it would require cultures. I think it should support running with invariant culture aswell.So after talking to someone on the discord server about it they said it has the following reason and told us to open a github issue about it.
eggsbox on Discord.NET's discord server:
Feel free to request any more information / reach out.