6

Today I logged into my Ubuntu server and noticed that Midnight Commander looks different:

strange question marks

Furthermore, I can't use functional keys (Mac keyboard with Fn key).

I tried to reinstall it, but with no luck. Can anybody help to fix this?

GNU Midnight Commander 4.8.11

Ubuntu 14.04.4 LTS (GNU/Linux 3.13.0-53-generic x86_64)

$ echo $TERM
ansi

I'm using macOS Teminal with oh-my-zsh.

$ sudo dpkg-reconfigure locales
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_CTYPE = "ru_RU.UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
Generating locales...
  en_US.UTF-8... up-to-date
Generation complete.


$ locale -a
locale: Cannot set LC_CTYPE to default locale: No such file or directory
C
C.UTF-8
en_US.utf8
POSIX

$ locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE=ru_RU.UTF-8
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
chimit
  • 201

2 Answers2

9

TL;DR: Running sudo dpkg-reconfigure locales and picking a UTF-8 locale usually fixes this.

As Joe Hart said in reply to strange "?" characters all over the screen in aptitude, mc and other ncurses programs (by Deboo ^) on the debian-user mailing list:

Usually this is a case of a character that is not defined in your current language settings (locale). You can usually fix this by chosing a UTF8 locale. dpkg-reconfigure locales should be able to fix your problem.

Specifically, the characters ncurses uses to draw borders aren't able to be displayed. Perhaps a non-UTF-8 locale got selected or your locales (or locale configuration) is broken. Ensuring you have a UTF-8 locale installed and selected as the default, and rebuilding your locales, stands a good chance of solving the problem.

Run:

sudo dpkg-reconfigure locales

Make sure at least one locale (of an appropriate language and region) that is marked as UTF-8 is selected on the first screen. You will have to scroll down (arrow keys). Spacebar selects or unselects an item, Tab switches between the list and the "buttons" below it, and Enter does roughly what you'd expect (it performs the default action for whatever is selected).

Configuring locales (screenshot), selecting locales to install

I've selected en_US.UTF8, but any UTF-8 locale should work. The first two letters, before the underscore (_), represent the language, and the letters right after the underscore represent the country.

Probably it will not look quite like that to you. Like mc, dpkg-reconfigure may display * characters instead of the characters it uses to draw the border. But this is purely cosmetic -- you should still be able to select and configure locales through this utility.

After you've pressed Tab and Enter to "click" the Ok button, you'll have to select the default locale. Make sure this is a UTF-8 locale (and that it's of the language and country you want). Move up and down with the arrow keys and press Enter when you get to the one you want. This will be set as your system's default locale, and all enabled locales will be (re)generated.

Configuring locales (screenshot), choosing a default locale

In new logins, the problem should be fixed.

If not, then please run locale -a and, separately, locale, and edit your question to add the output of each. Other users with a similar problem who find this post when searching for help should of course not edit this question, but should instead ask a new question with a detailed description of their problem as well as a link to this one for context.

Eliah Kagan
  • 119,640
4

The problem was in my Terminal in macOS. I used a "Solarized Dark" theme, which had a setting "Set terminal as" set to ansi in "Terminfo" section. The solution is to change it to xterm-256color.

chimit
  • 201