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

LANG environment variable not set #7053

Closed
waynerv opened this issue Jul 4, 2023 · 10 comments
Closed

LANG environment variable not set #7053

waynerv opened this issue Jul 4, 2023 · 10 comments

Comments

@waynerv
Copy link

waynerv commented Jul 4, 2023

For bug reports, the following information can help speed up the process. Please
describe the bug that you have found and what you would expect to happen
instead.

System

OS: macOS
Version: alacritty 0.12.2 (9d9982d)

LANG env not set after startup,works fine in local but after ssh to remote neovim checkhealth complains:

ERROR Locale does not support UTF-8. Unicode characters may not dispaly correctly.
$LANG=C.UTF-8 $LC_ALL=nil $LC_CTYPE=UTF-8

localhost locale output:

LANG=""
LC_COLLATE="C"
LC_CTYPE="UTF-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=

Is keep LANG unset a expect behavior ? Not sure about this because seen a merged PR to set $LANG env var using languageCode, countryCode: #1087

@chrisduerr
Copy link
Member

Sounds like the system you're SSH'ing into is fucked. It probably doesn't have your locale generated.

@waynerv
Copy link
Author

waynerv commented Jul 4, 2023

@chrisduerr Does this mean I should set the LANG environment variable manually?

I can set envs section in cofiguration file to fix this, howerver iTerm2 and kitty automaticlly handled LANG env.

@kchibisov
Copy link
Member

@chrisduerr Does this mean I should set the LANG environment variable manually?

Is your remote server takes the locale of you host upon connecting? That would be strange to be honest, usually your remote server should have its locale set, like configured in /etc/locale.conf, etc.

@kchibisov
Copy link
Member

It seems that at least iterm is setting LANG based on the macOS system preference lang variable, which is a bit weird, but isn't that complicated from what I can see

https://github.com/gnachman/iTerm2/blob/master/sources/PTYSession.m#L2524

This is all weird, but whatever... As a workaround you could set LANG in env section of alacritty.

@waynerv
Copy link
Author

waynerv commented Jul 4, 2023

@chrisduerr Does this mean I should set the LANG environment variable manually?

Is your remote server takes the locale of you host upon connecting? That would be strange to be honest, usually your remote server should have its locale set, like configured in /etc/locale.conf, etc.

I think the problem lies in LC_CTYPE env being set to UTF-8, which is obviously an invalid value. The correct value should be something like 'C.UTF-8' or 'en_US.UTF-8'. Not sure if this is related to alacritty.

alacritty -vv prints:
[0.002248002s] [DEBUG] [alacritty] Using environment locale: C/UTF-8/C/C/C/C

@chrisduerr
Copy link
Member

It seems that at least iterm is setting LANG based on the macOS system preference lang variable, which is a bit weird, but isn't that complicated from what I can see

So does Alacritty. Why did you reopen this issue?

[0.002248002s] [DEBUG] [alacritty] Using environment locale: C/UTF-8/C/C/C/C

That means you have your locale set manually, which Alacritty will not override.

@kchibisov
Copy link
Member

So does Alacritty. Why did you reopen this issue?

We don't set LANG if you look into our macOS code, that's why I've reopened it. At least I don't see that we really set it to anything.

I think the problem lies in LC_CTYPE env being set to UTF-8, which is obviously an invalid value. The correct value should be something like 'C.UTF-8' or 'en_US.UTF-8'. Not sure if this is related to alacritty.

Locale on macOS is weird, they use plain UTF-8 thing and it's common.

@chrisduerr
Copy link
Member

We don't set LANG if you look into our macOS code, that's why I've reopened it. At least I don't see that we really set it to anything.

We don't need to set LANG, we set LC_ALL after which setting LANG is pointless.

@chrisduerr
Copy link
Member

You can try the following patch, that might fix things:

diff --git a/alacritty/src/macos/locale.rs b/alacritty/src/macos/locale.rs
index 2a47ace8..6750e56d 100644
--- a/alacritty/src/macos/locale.rs
+++ b/alacritty/src/macos/locale.rs
@@ -18,7 +18,7 @@ pub fn set_locale_environment() {
         let env_locale = unsafe { CStr::from_ptr(env_locale_ptr).to_string_lossy() };
 
         // Assume `C` locale means unchanged, since it is the default anyways.
-        if env_locale != "C" {
+        if !env_locale.is_empty() && env_locale != "C" {
             debug!("Using environment locale: {}", env_locale);
             return;
         }

But this very much looks like you messed with your locale in your env and your system is broken because of it.

@waynerv
Copy link
Author

waynerv commented Jul 5, 2023

To make it work, I will simply set the LANG environment in the configuration file.

Building from source is too difficult for me since I am not familiar with Rust.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants