Is Rider overriding how the culture is being determined?
When running a dotnet app (.NET 5 on the Mac) via Rider's terminal, it appears to be overriding how the culture is determined. E.g. when printing to the console, `System.Globalization.CultureInfo.CurrentCulture.NativeName` I get back, "Invariant Language (Invariant Country) ", as opposed to the expected, "English (United Kingdom)" - I'm currently in the UK. Conversely, when running the app via the stock OS terminal, the correct culture is being used.
This is causing issues in development as all the dates are not in the anticipated format of my locale. According to https://docs.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo.currentculture?view=net-5.0#how-a-threads-culture-is-determined, the culture should be determined via the OS.
Any pointers would be appreciated.
Please sign in to leave a comment.
I'm seeing the same thing. Just started using Rider last couple of weeks and haven't resolved it yet.
I am seeing `CurrentCulture = en-US` and `CurrentUICulture = IV`
Hi Robin - where are you located?
It would be great if there was a way to trace how the culture is being determined at a granular level.
UK. In terminal, I get the following with locale:
LANG="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_CTYPE="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_ALL=
And with .GlobalPreferences:
"en-GB"
Hello D Pedder, Robin
I guess it might be a problem with some environment variables, which are invisible to Rider. Please try to run Rider from the OS terminal in opposed to running it via a shortcut. What do you get after printing `
System.Globalization.CultureInfo.CurrentCulture.NativeName`in this case?Julia - that worked great, I got back the expected culture. Thanks for that.
A few questions:
1. While as a short term solution this works fine, is there anything else I can try/do to ensure the culture is correct and again launch Rider via Spotlight?
2. Is this an issue that can be resolved by the team at some point?
D Pedder
1. I'm struggling to google where LANG an LC_* variables are defined on mac but to no avail. As Rider doesn't see them, they must be shell-specific, not global ones. I've ended up googling here and here for now.
2. I have a strong feeling that Rider is not to blame. To my understanding, environment variables on Mac differ between (all) GUI applications and within the terminal. Did you try to check if your application works the same if you run it from another IDE?
Thanks for that Julia.
I've done a little more digging and found a more permanent solution. It appears to be possible to set your systems locale by setting the LANG env variable. For instance, to set the locale to the UK, simply add `export LANG=en_GB.UTF-8` to your .bash_profile.
See this Oracle page for more info - https://docs.oracle.com/cd/E23824_01/html/E26033/glmha.html
Re. trying the app in a different IDE, you're correct in your assumption. VS Code was also setting the locale incorrectly (en-US). Thankfully, after setting the LANG variable this fixes both VS Code and Rider.
D Pedder
Thanks for sharing your research. It's nice to hear that everything works now.