pg-formatter icon indicating copy to clipboard operation
pg-formatter copied to clipboard

Locale issues on Windows

Open asherber opened this issue 8 months ago • 3 comments

I'm using the Strawberry Perl distro on Windows, along with Node 20.10.0. When I invoke pg-formatter out of the box, it does what it's supposed to, but then it also outputs:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LC_ALL = "C.UTF-8",
        (possibly more locale environment variables)
        LANG = (unset)
    are supported and installed on your system.
perl: warning: Falling back to the system default locale ("English_United States.1252").

I'm a newbie with Perl and haven't been able to find much info about locale handling on Windows. But after a lot of poking around, I tracked this down to: https://github.com/gajus/pg-formatter/blob/6e1c8aff43ceaad27364e5628d11a7a68b3bec8b/src/format.ts#L121-L123

If I change the value of LC_ALL to C on line 122, then everything works fine with no warnings. (It also works if I remove lines 121-123 entirely.)

Is using C an appropriate fix on Windows? Or is there a better approach? In either case, can this be built into pg-formatter by checking process.platform?

asherber avatar Nov 26 '23 00:11 asherber

You could also start perl with the -X flag to disable all warnings (Have not tested the output of this).

yoganlava avatar Dec 16 '23 23:12 yoganlava

@gajus C.UTF-8 making script unusable on macOS – it is flooding with following statement right inside the code

perl: warning: Falling back TO the standard locale ("C").
perl: warning: Setting locale failed. 
perl: warning: Please CHECK that your locale settings: LC_ALL = "C.UTF-8", LANG = (unset) are supported AND installed ON your system.

Removing env section fixes all issues. Please consider applying that change.

vikseriq avatar Dec 28 '23 23:12 vikseriq

This bug is preventing me from adopting eslint-plugin-sql.

MatthewMaclean avatar Feb 15 '24 22:02 MatthewMaclean