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

Allows to set environment variables of Postgres #147

Closed
wants to merge 1 commit into from

Conversation

MarcMil
Copy link

@MarcMil MarcMil commented Feb 5, 2025

On some misconfigured linux systems we've encountered "error: invalid locale settings; check LANG and LC_* environment variables". Since we intend to use Postgres in our application on customer machines, we want Postgres to work even in those conditions.

On some misconfigured linux systems we've encountered "error: invalid locale settings; check LANG and LC_* environment variables". Since we intend to use Postgres in our application on customer machines, we want Postgres to work even in those conditions.
@tomix26
Copy link
Collaborator

tomix26 commented Feb 6, 2025

Rather than allowing arbitrary environment variable settings, I would prefer having meaningful default values that work under any conditions, so the library user doesn’t have to deal with this at all.

If I understand correctly, the LC_* environment variables are just default values that can later be overridden when calling the initdb command? If so, this should already be possible using the EmbeddedPostgres.Builder#setLocaleConfig() method.

In that case, the problem could be resolved by setting some reasonable defaults, such as:

LANG="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"

Alternatively, resetting the environment variables might also work:

LANG=""
LC_ALL=""
LC_CTYPE=""

Could you please confirm whether my assumptions are valid? Thanks!

@MarcMil
Copy link
Author

MarcMil commented Feb 6, 2025

You're correct! Thanks for the hint.
Unsetting the variable does not seem to cause issues, postgres is using the C locale then as a fallback. However, I could replicate the customer's error message when setting the environment variables to non-conforming values.
It then works when I use setLocaleConfig("locale", "en_US.UTF-8");; that takes precedence over the environment values.

I'll close this issue then. Thanks!

@MarcMil MarcMil closed this Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants