Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locale issues on Windows #34

Open
asherber opened this issue Nov 26, 2023 · 3 comments · May be fixed by #35
Open

Locale issues on Windows #34

asherber opened this issue Nov 26, 2023 · 3 comments · May be fixed by #35

Comments

@asherber
Copy link

asherber commented Nov 26, 2023

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:

pg-formatter/src/format.ts

Lines 121 to 123 in 6e1c8af

env: {
LC_ALL: 'C.UTF-8',
},

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?

@yoganlava
Copy link

yoganlava commented Dec 16, 2023

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

@vikseriq
Copy link

@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.

@MatthewMaclean
Copy link

MatthewMaclean commented Feb 15, 2024

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

nwjsmith added a commit to nwjsmith/pg-formatter that referenced this issue Mar 6, 2024
It is safe to run the `pg_format` executable without hard-coding the locale.

Fixes gajus#34
@nwjsmith nwjsmith linked a pull request Mar 6, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants