Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

For some reason, today, everytime 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?

share|improve this question
    
Is en_CA (i.e. Canadian English) a locale you expected to be in? –  Gilles May 3 '11 at 6:59
1  
can you post the output of the locale command? –  penguin359 May 6 '11 at 7:44
1  
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

5 Answers 5

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

share|improve this answer

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.

share|improve this answer
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

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

share|improve this answer
    
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

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

share|improve this answer

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!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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