Strovent SystemsSign in
Reference

Mosh "needs a UTF-8 native locale to run"

Why Mosh stops with "needs a UTF-8 native locale to run", whether the client or the server complains, and how to set a UTF-8 locale on each side.

Mosh only runs when the text path is UTF-8 on both ends. If it is not, one of two programs prints this and exits:

mosh-server needs a UTF-8 native locale to run.

Unfortunately, the local environment (LANG=C) specifies
the character set "ANSI_X3.4-1968",

or

mosh-client needs a UTF-8 native locale to run.

The first is the host's mosh-server. The second is the client on the computer you typed mosh on. Each prints the locale variables it saw and the output of the locale command. That output tells you which side to change.

How Mosh picks a locale

From the Mosh manual: the client must have locale variables that name UTF-8. mosh passes them to mosh-server on its command line. The server first tries its own locale variables, from the system default (sometimes /etc/default/locale) or passed over SSH. If those are not UTF-8, it applies the client's variables and checks again. The error appears when neither gives UTF-8.

Fix it

  1. See both sides. On the client, run locale. On the host, run ssh [email protected] locale. Both need a UTF-8 value, for example LC_CTYPE="en_US.UTF-8".
  2. Set the client first. In the shell's startup file, for example export LANG=en_US.UTF-8. Use a name that exists on that system, shown by locale -a.
  3. Set the host. The same line in the account's shell startup file on the host, or ask the administrator to set the system default. If en_US.UTF-8 does not exist there, use any UTF-8 locale that does, such as the one locale -a lists. The two sides may use different names.
  4. Set it for one run if you cannot change the host files. The Mosh FAQ gives this form:
mosh --server="LANG=en_US.UTF-8 mosh-server" [email protected]

You may also have to set LANG locally for mosh-client.

Why Mosh insists

The Mosh FAQ says it is much easier to implement one terminal emulator correctly than to handle many character sets. So Mosh does not start until UTF-8 is in place on both ends.

After the error, the usual next message is "Did not find mosh server startup message": see Mosh "Did not find mosh server startup message".

Sources

Spotted a mistake? Email [email protected].