<div dir="ltr">Hello Goffredo,<div><br></div><div>I'm afraid there's no good answer here within the context of the C/POSIX locale system. If mosh didn't complain, some other locale-sensitive program on the server would complain (e.g. perl, or basically anything). ssh (as shipped by OS X/Debian/Ubuntu) also passes the locale-related environment variables, and you would have the same problem there.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">We're moving to a world where Mosh will not use the C locale support at all to do UTF-8 decoding and get character widths, but that will just make this somebody else's problem.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">Your good options are basically:</div><div class="gmail_extra">(1) Unset LC_TIME before you mosh (e.g. LC_TIME= mosh servername).</div><div class="gmail_extra">
(2) Build the client's locale on the server.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">-Keith</div><div class="gmail_extra"><br></div><div class="gmail_extra">On Tue, Dec 10, 2013 at 2:23 PM, Goffredo Baroncelli <span dir="ltr"><<a href="mailto:kreijack@inwind.it" target="_blank">kreijack@inwind.it</a>></span> wrote:<br>
</div><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Keith,<br>
<div><br>
On 2013-12-10 20:11, Keith Winstein wrote:<br>
> Goffredo,<br>
><br>
> Unfortunately this is a general problem with the C/POSIX locale system.<br>
> Even British users (in en_GB.UTF-8) have trouble connecting to Canadian<br>
> machines in (en_CA.UTF-8)! If you give us the actual error report you're<br>
> getting from mosh-client or mosh-server, I may have a better answer for<br>
> what the right thing to do is. We have made the diagnostics pretty<br>
> extensive in 1.2 and later versions.<br>
<br>
<br>
<br>
</div>-------------------------------------client-------------------------<br>
server$ set | egrep "LANG|LC_"<br>
LANG=en_US.UTF-8<br>
LC_TIME=en_DK.utf8 # this var is set by ssh<br>
server$ locale -a<br>
C<br>
C.UTF-8<br>
en_US.utf8<br>
italian<br>
it_IT<br>
it_IT@euro<br>
it_IT.iso88591<br>
it_IT.iso885915@euro<br>
it_IT.utf8<br>
POSIX<br>
$ mosh --version<br>
mosh 1.2.4a<br>
Copyright 2012 Keith Winstein <<a href="mailto:mosh-devel@mit.edu" target="_blank">mosh-devel@mit.edu</a>><br>
License GPLv3+: GNU GPL version 3 or later<br>
<<a href="http://gnu.org/licenses/gpl.html" target="_blank">http://gnu.org/licenses/gpl.html</a>>.<br>
This is free software: you are free to change and redistribute it.<br>
There is NO WARRANTY, to the extent permitted by law.<br>
<br>
<br>
-------------------------------------server-------------------------<br>
client$ set | egrep "LANG|LC_"<br>
LANG=en_US.utf8<br>
LC_TIME=en_DK.utf8<br>
client$ locale -a<br>
C<br>
C.UTF-8<br>
en_DK.utf8<br>
en_US.utf8<br>
italian<br>
it_IT<br>
it_IT@euro<br>
it_IT.iso88591<br>
it_IT.iso885915@euro<br>
it_IT.utf8<br>
POSIX<br>
client$ mosh --version<br>
mosh 1.2.4a<br>
Copyright 2012 Keith Winstein <<a href="mailto:mosh-devel@mit.edu" target="_blank">mosh-devel@mit.edu</a>><br>
License GPLv3+: GNU GPL version 3 or later<br>
<<a href="http://gnu.org/licenses/gpl.html" target="_blank">http://gnu.org/licenses/gpl.html</a>>.<br>
This is free software: you are free to change and redistribute it.<br>
There is NO WARRANTY, to the extent permitted by law.<br>
---------------------------------------------------------------------------<br>
<br>
<br>
Both the machine support en_US.utf8; however the client has<br>
LC_TIME=en_DK.utf8 which isn't supported in the server.<br>
<br>
<br>
<br>
client$ mosh server<br>
ghigo@client's password:<br>
The locale requested by LANG=en_US.UTF-8 isn't available here.<br>
Running `locale-gen en_US.UTF-8' may be necessary.<br>
<br>
The locale requested by LANG=en_US.utf8 isn't available here.<br>
Running `locale-gen en_US.utf8' may be necessary.<br>
<br>
mosh-server needs a UTF-8 native locale to run.<br>
<br>
Unfortunately, the local environment (LANG=en_US.UTF-8) specifies<br>
the character set "US-ASCII",<br>
<br>
The client-supplied environment (LANG=en_US.utf8) specifies<br>
the character set "US-ASCII".<br>
<br>
locale: Cannot set LC_ALL to default locale: No such file or directory<br>
LANG=en_US.utf8<br>
LANGUAGE=<br>
LC_CTYPE="en_US.utf8"<br>
LC_NUMERIC="en_US.utf8"<br>
LC_TIME=en_DK.utf8<br>
LC_COLLATE="en_US.utf8"<br>
LC_MONETARY="en_US.utf8"<br>
LC_MESSAGES="en_US.utf8"<br>
LC_PAPER="en_US.utf8"<br>
LC_NAME="en_US.utf8"<br>
LC_ADDRESS="en_US.utf8"<br>
LC_TELEPHONE="en_US.utf8"<br>
LC_MEASUREMENT="en_US.utf8"<br>
LC_IDENTIFICATION="en_US.utf8"<br>
LC_ALL=<br>
Connection to server closed.<br>
/usr/bin/mosh: Did not find mosh server startup message.<br>
ghigo@venice:~$<br>
<br>
<br>
If I do<br>
<br>
$ LC_TIME= mosh server<br>
ghigo@server's password:<br>
<br>
server$<br>
<br>
Everything is OK.<br>
<div><br>
<br>
<br>
><br>
> I'm guessing the "right answer" will involve building a locale on your<br>
> client that matches something the server can do, but I'll defer judgment<br>
> until I can see the diagnostic output.<br>
><br>
> Best regards,<br>
> Keith<br>
><br>
><br>
> On Tue, Dec 10, 2013 at 6:20 AM, Goffredo Baroncelli <<a href="mailto:kreijack@libero.it" target="_blank">kreijack@libero.it</a><br>
</div><div><div>> <mailto:<a href="mailto:kreijack@libero.it" target="_blank">kreijack@libero.it</a>>> wrote:<br>
><br>
> Hi all,<br>
><br>
> I am facing the problem related to locale, when the host locale doesn't<br>
> match with the server locale.<br>
><br>
> The reason is that I have an uncommon setting of the environment<br>
> variable LC_TIME, which is set to en_DK.utf8 [1].<br>
><br>
> To avoid this problem I have to call mosh as below<br>
><br>
> LC_TIME= mosh <server><br>
><br>
> and everything work properly.<br>
><br>
> Looking at the code, I noticed that in set_native_locale(), it is called<br>
> setlocale( LC_ALL, "" ).<br>
> Unfortunately this function fails even if *one* setting of the LC_*<br>
> doesn't match. This is what I saw.<br>
><br>
> However I suppose that mosh should care only about the LC_CTYPE setting.<br>
> If so, the following patch should narrow the cases where mosh fails when<br>
> the environments differ.<br>
><br>
> diff --git a/src/util/locale_utils.cc b/src/util/locale_utils.cc<br>
> index 11923ff..9e9eb0c 100644<br>
> --- a/src/util/locale_utils.cc<br>
> +++ b/src/util/locale_utils.cc<br>
> @@ -95,7 +95,7 @@ bool is_utf8_locale( void ) {<br>
><br>
> void set_native_locale( void ) {<br>
> /* Adopt native locale */<br>
> - if ( NULL == setlocale( LC_ALL, "" ) ) {<br>
> + if ( NULL == setlocale( LC_CTYPE, "" ) ) {<br>
> int saved_errno = errno;<br>
> if ( saved_errno == ENOENT ) {<br>
> LocaleVar ctype( get_ctype() );<br>
><br>
><br>
> In my case it works, but I don't know very well how mosh interact with<br>
> locale.<br>
><br>
> Comments ?<br>
><br>
> BR<br>
> G.Baroncelli<br>
><br>
> [1] For the record, I have this setting to see in thunderbird a "date<br>
> which is readable.... but this is another story.<br>
><br>
> --<br>
</div></div>> gpg @<a href="http://keyserver.linux.it" target="_blank">keyserver.linux.it</a> <<a href="http://keyserver.linux.it" target="_blank">http://keyserver.linux.it</a>>: Goffredo<br>
<div>> Baroncelli (kreijackATinwind.it><br>
> Key fingerprint BBF5 1610 0B64 DAC6 5F7D 17B2 0EDA 9B37 8B82 E0B5<br>
> _______________________________________________<br>
> mosh-devel mailing list<br>
</div>> <a href="mailto:mosh-devel@mit.edu" target="_blank">mosh-devel@mit.edu</a> <mailto:<a href="mailto:mosh-devel@mit.edu" target="_blank">mosh-devel@mit.edu</a>><br>
> <a href="http://mailman.mit.edu/mailman/listinfo/mosh-devel" target="_blank">http://mailman.mit.edu/mailman/listinfo/mosh-devel</a><br>
<div><div>><br>
><br>
<br>
<br>
--<br>
gpg @<a href="http://keyserver.linux.it" target="_blank">keyserver.linux.it</a>: Goffredo Baroncelli (kreijackATinwind.it><br>
Key fingerprint BBF5 1610 0B64 DAC6 5F7D 17B2 0EDA 9B37 8B82 E0B5<br>
</div></div></blockquote></div><br></div></div>