5

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
  • 181
  • 1
  • 8
  • 2
    Please edit your post to include the output of echo $TERM and which application you're using to connect to this server. – muru Jan 16 '17 at 07:51
  • 1
    and do a set TERM=xterm && export TERM and try mc again ;) – Rinzwind Jan 16 '17 at 08:12
  • muru, done!

    @Rinzwind, no changes.

    – chimit Jan 16 '17 at 08:18
  • @Mac odd. I can reproduce your problem if I do TERM=ansi mc, and it works ok for TERM=xterm mc – muru Jan 16 '17 at 08:54
  • @muru TERM=xterm mc fixed the problem! But how can I make this behavior permanent? – chimit Jan 16 '17 at 09:57
  • 1
    When you just open Terminal, is echo $TERM ansi? Do you have anything in your .bashrc or the like which sets TERM? – muru Jan 16 '17 at 10:19
  • The problem was in my Terminal theme settings: http://askubuntu.com/questions/872459/question-marks-in-midnight-commander?noredirect=1#comment1354133_872467

    Thank you, @muru and @rinzwind!

    – chimit Jan 17 '17 at 03:41
  • @Mac you should post it as the answer – muru Jan 17 '17 at 03:42

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
  • 117,780
  • Thank you for so detailed answer, Eliah! Unfortunately, I still have this problem. Added sudo dpkg-reconfigure locales output into the question. – chimit Jan 16 '17 at 09:45
  • @Mac Thanks for the added information. It looks like there is something wrong with your current locale, but apparently not something that dpkg-reconfigure locales fixed. (Perhaps the problem is specific to your user account rather than the whole system.) Does the problem still occur when you run LC_ALL=C mc instead of mc? This would be a workaround rather than a full solution, but may provide some insight into what is going wrong. – Eliah Kagan Jan 16 '17 at 09:48
  • $ LC_ALL=C mc gives the same mc with question marks.

    I have this problem under all user accounts in the system.

    – chimit Jan 16 '17 at 09:53
  • 1
    @Mac Does sudo apt-get update && sudo apt-get --purge --reinstall install language-pack-en-base (and logging out and in) help? If not, are you connecting via SSH? If you have physical access (or another way that's not SSH-based), does the problem occur when you run mc that way, or just over SSH? If it's only when you connect through SSH, or you don't know because SSH is the only way you have to connect, then might you be specifying an unsupported locale in the client's SSH configuration? Is there a SendEnv LANG ... line in the client's ssh_config? – Eliah Kagan Jan 16 '17 at 10:04
  • I tried to launch mc on my local macOS (without SSH connection to the server) and saw the same problem. Looks like the problem is in my system.

    My ~/.ssh/config on macOS doesn't have SendEnv LANG LC_*.

    – chimit Jan 17 '17 at 03:26
  • I finally found a solution! The problem was in my terminal theme "Solarized Dark". On the last tab of theme customization in the section "Terminfo" a setting "Set terminal as" was set to ansi, while the default "Basic" theme has this setting is set to xterm-256color. I changed it to this option and the problem gone.

    Thank you, @eliah-kagan! I would never guess where the problem lies without your help!

    – chimit Jan 17 '17 at 03:37
  • @Mac I'm glad to have contributed! Though muru's idea was closer -- I suggested locale settings (server or client), while muru suggested it could be the terminal type. My answer can remain for others who experience this problem in ncurses programs -- I expect the advice Joe Hart gave on debian-users to help some other Ubuntu users even though it didn't solve the problem for you -- but, as muru says, you should post your solution as an answer so it will help other users, too. – Eliah Kagan Jan 17 '17 at 03:58
3

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
  • 181
  • 1
  • 8