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?

  • Is en_CA (i.e. Canadian English) a locale you expected to be in? – Gilles May 3 '11 at 6:59
  • 2
    can you post the output of the locale command? – penguin359 May 6 '11 at 7: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)? – user3269 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 5 '18 at 15:52

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

  • 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 7 '13 at 2:46

Similar problem when connecting via SSH to a remote sever (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 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


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:


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

  • 3
    Fixing LC_CTYPE to be a valid value did it. You don't need LANG (and in fact I recommend against it). You can see the valid locale names on your system by running locale -a. On Ubuntu, run sudo localegen xx_YY to generate the xx_YY locale (assuming it can be generated). – Gilles Aug 9 '11 at 22:39

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


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!


Solved permanently with creating file


With contents


See answer at github

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.