13

For some reason today, every time I hit tab in the terminal, this shows up:

cat bash: warning: setlocale: LC_CTYPE: cannot change locale (en_CA)

Display all 150 possibilities? (y or n)

This particular one happens when I type cat then hit TAB. I never changed any setting or anything. Anyone know what's going on?

dan
  • 933
TAB Weirdness
  • 131
  • 1
  • 3
  • Is en_CA (i.e. Canadian English) a locale you expected to be in? – Gilles 'SO- stop being evil' May 03 '11 at 06:59
  • 2
    can you post the output of the locale command? – penguin359 May 06 '11 at 07:44
  • 2
    Are you sure that en_CA is a valid locale (that is, it both exists on your system, and has been generated by localedef or some similar locale generation tool)? –  Jul 15 '11 at 12:57
  • If you want a correct answer, please answer the question from @penguin359 , and tell how you are connected on your system (directly on the console or remotely with ssh or putty. – dan Feb 05 '18 at 15:52

6 Answers6

8

I have a hunch that something your bash_completion is causing this to happen. Try clearing out your bash completion temporarily (until you exit) by doing:

complete -r

If that clears it up then it's something with bash completion, if not it still might be one of the bash built-ins

Gekitsuu
  • 116
  • Tried this solution last, because the others seemed like a more appropriate solution to a problem that had persisted for ages, but this was the one that worked. – The Unfun Cat Nov 07 '13 at 02:46
5

I had a similar problem when connecting via SSH to a remote server (after having installed oh-my-zsh on my local, but I'm not sure that's relevant).

To fix it, on my local machine, I edited the /etc/ssh/ssh_config file, commenting out the SendEnv line.

#SendEnv LANG LC_*

Tab completion now works without the warning on the remote machine.

bash: warning: setlocale: LC_CTYPE: cannot change locale

karel
  • 2,030
acw
  • 151
4

I've had similar problem on my ubuntu server (FlexiScale) and searched for a solution for a while but could not find anything suitable... Still not sure if what I did is the "right way", but it seems to work.

The warning I was seeing was:

bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8)

To make sure the locales are up-to-date I did this (not sure if this was neccessary):

# locale-gen --purge

locale on my system was showing LC_CTYPE="UTF-8" which didn't look right to me, so I've changed my /etc/default/locale to look like this:

LANG="en_GB.UTF-8"
LC_CTYPE="en_GB.UTF-8"

(I've added the second line.) After re-login the warnings were gone.

inkredibl
  • 141
1

If you get error/warning message similar to this when press Tab for bash command autocompletion :

bash: warning: setlocale: LC_CTYPE: cannot change locale (id_ID.UTF-8)

Solution is:

  1. Install the required locale. In my case this is the "id" :

    sudo apt-get install language-pack-id
    
  2. Reconfigure locales:

    sudo dpkg-reconfigure locales
    

Now bash Tab completion should work just fine. :-)

Source: http://ubuntucomputing.blogspot.com/2011/12/how-to-fix-error-bash-warning-setlocale.html

0

I was having the same problem. I had tried some of the solutions here, but when I tried to run locale-gen, my system said it couldn't find the command. It turns out that it's a part of the locales package that I didn't have installed. So I installed it, ran locales-gen, and now it works!

user394
  • 14,404
  • 21
  • 67
  • 93
0

Solved permanently with creating file

/etc/default/locale

With contents

LC_ALL="en_US.UTF-8"

See answer at github