[mosh-devel] Mosh and setlocale(LC_ALL,"")

Keith Winstein keithw at MIT.EDU
Tue Dec 10 16:36:55 EST 2013


Hello Goffredo,

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.

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.

Your good options are basically:
(1) Unset LC_TIME before you mosh (e.g. LC_TIME= mosh servername).
(2) Build the client's locale on the server.

-Keith

On Tue, Dec 10, 2013 at 2:23 PM, Goffredo Baroncelli <kreijack at inwind.it>wrote:

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


More information about the mosh-devel mailing list