12.6 C
Jaipur
Tuesday, December 7, 2021

macOS setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory

Must read

I am a new Apple OS X Mabbook user. I am getting an error which read as follows when I connect to any remote Linux/Unix/BSD server or machine through OS X ssh Terminal app:
ssh [email protected]iti.biz
Last login: Wed Mar 26 08:45:36 2014 from 1.2.3.4
-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
How do I fix this error?

Tutorial details
Difficulty level Easy
Root privileges No
Requirements Apple OS X/macOS
Est. reading time 2 minutes

Let us see how to fix the LC_CTYPE: cannot change locale (UTF-8) error on macOS or OS X terminal client or remote OpenSSHD server. This warning or error is part of both OpenSSH server and macOS or OS X ssh terminal client issue. It can be fixed using various methods.

Understanding LC_* environment variables

Type the following command on remote server to display of all locales supported by Glibc:

$ locale -a

Next, type the following command to display settings on your local system (OSX/Unix/Linux based desktop):

printenv
echo "$LC_CTYPE"

Sample outputs:

UTF-8

The above commands display the country and language names, the character encoding used by the locale. Your local ssh client is sending your LC_* environment variables to remote sshd server. In other words, SSH will try to set every LC_* variable you have set on your local OSX system on the remote server too. Here is an example of such problem:

Fig 01: warning setlocale lc_ctype cannot change locale (utf-8)

Fixing the LC_CTYPE: cannot change locale (UTF-8) error on Linux/OS X

This can be fixed as follows:

Method #1: If you are using the Terminal app on OS X

If you are using the ‘Terminal’ app then click on

Patreon supporters only guides 🤓

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare
  • Join my Patreon to support independent content creators and start reading latest guides:

Join Patreon

Terminal > Preferences > Select Terminal type such as Basic (default) > Advanced tab

Make sure that the ‘Set locale environment variables on startup’ is unchecked as follows:

Fig.02: Fixing OS X terminal by unsetting ‘Set locale environment variables on startup’ check box

Here is another screenshot from MacOS X v10.11.6:

Fig.03: Unsetting ‘Set locale environment variables on startup’ check box on OS X EI Caption

You must close all ssh session and relaunch Terminal app.

-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory fix on macOS

The options are as follows on the latest version of macOS:

macos -bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8) fix (click to enlarge)

Method #2: Preventing OpenSSH Client from sending the LC_* variables on OS X / Linux / Unix desktop

Edit /etc/ssh/ssh_config or /etc/ssh_config file, enter:

$ sudo vi ~/.ssh/config

Remove or comment out as follows:

Save and close the file.

Method #3: Install required locale on the remote server

Finally, you can fix this problem either installing the desired locale using the localedef command, or consider choosing a different locale in locale/remote system:

# localedef -i en_US -f UTF-8 en_US.UTF-8

Summing up

When using the ‘Terminal‘ app under macOS always search for the ‘Advanced‘ tab in the ‘Settings‘. Then make sure that the ‘Set locale environment variables on startup‘ is set as per your need. Other options are like editing ~/.ssh/config file to fix warning setlocale lc_ctype cannot change locale (utf-8) under macOS or OS X terminal.


ADVERTISEMENT

Source link

- Advertisement -

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement -

Latest article