Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default locale is set to en_US.UTF-8 but it's missing #71

Closed
robinst opened this issue Dec 14, 2016 · 24 comments
Closed

Default locale is set to en_US.UTF-8 but it's missing #71

robinst opened this issue Dec 14, 2016 · 24 comments

Comments

@robinst
Copy link

robinst commented Dec 14, 2016

We use the CentOS 7 image for testing, and have had an error related to locales that started happening only a few days ago. Steps to reproduce:

Using the following Dockerfile:

FROM centos:7
RUN yum -y install gcc libmemcached-devel

Build it:

$ docker build .

Run the build image:

$ docker run -ti ab7f114ea298
bash: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory
bash: warning: setlocale: LC_COLLATE: cannot change locale (en_US.UTF-8): No such file or directory
bash: warning: setlocale: LC_MESSAGES: cannot change locale (en_US.UTF-8): No such file or directory
bash: warning: setlocale: LC_NUMERIC: cannot change locale (en_US.UTF-8): No such file or directory
bash: warning: setlocale: LC_TIME: cannot change locale (en_US.UTF-8): No such file or directory
[root@476f2cc9c761 /]# locale  
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES 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
LC_CTYPE="en_US.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=
[root@476f2cc9c761 /]# locale -a
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_COLLATE to default locale: No such file or directory
C
POSIX
[root@476f2cc9c761 /]# cat /etc/locale.conf
LANG="en_US.UTF-8"

We narrowed it down to the combination of the two packages gcc and libmemcached-devel. If just installing either one on its own, the problem doesn't occur. libmemcached-devel seems to pull in a package that creates /etc/profile.d/lang.sh which seems to be the thing setting the locale.

But somehow in that yum transaction, the locales seem to not be built properly, as you can see in the locale -a output above.

@robinst
Copy link
Author

robinst commented Dec 14, 2016

Here's the full output of docker build .: https://gist.github.com/robinst/65087930a385a0187b3f1cfa95150f35

Any ideas?

@robinst
Copy link
Author

robinst commented Dec 14, 2016

It looks like the following might be a workaround until this is fixed:

localedef -i en_US -f UTF-8 en_US.UTF-8

@remy-tiitre
Copy link

The same is happening for us and it related to gcc update. It will happen even when you create Dockerfile

@remy-tiitre
Copy link

FROM centos:7
...
RUN yum -y update
...

This will update gcc and screw up locale. Very annoing, as in general I avoid running yum update but unfortunately for Selenium I need to install chrome and it will do it anyway.

@andrewmichaelsmith
Copy link

andrewmichaelsmith commented Dec 14, 2016

Also seeing this issue just now:

$ docker run -ti centos bash
[root@f3d33016349f /]# locale -a
C
POSIX
en_US.utf8
[root@f3d33016349f /]# yum install -y glibc
Loaded plugins: fastestmirror, ovl
base
....
....<snipped for brevity>....
....
Complete!
[root@f3d33016349f /]# locale -a               
C
POSIX

Around a month ago we were not hitting this issue.

@remy-tiitre
Copy link

I think we just need up to date centos docker image (CentOS-7 (1611)). Probably yum updates something it shouldn't.

@andrewmichaelsmith
Copy link

@remy-tiitre For us, we don't want to immediately take 1611 so ideally there would be a solution that doesn't involve taking that immediately.

As @robinst suggests, our current workaround is to just run localedef -i en_US -f UTF-8 en_US.UTF-8 after our yum install.

@remy-tiitre
Copy link

remy-tiitre commented Dec 14, 2016

I'm not even sure that 1611 fixes it, but there should be a Docker image for that for sure. Hopefully it will be created soon. localedef is a solution for most cases but it gets annoing if you use https://chrome.richardlloyd.org.uk/ install_chrome.sh or any other script like that (you have to modify the script itself). I also noticed some other warnings that usually I would like to avoid in my docker containers :)
warning: /etc/nsswitch.conf created as /etc/nsswitch.conf.rpmnew
line 1: /etc/sysconfig/network-scripts/network-functions: No such file or directory
warning: %triggerin(systemd-219-30.el7_3.6.x86_64) scriptlet failed, exit status 1
install-info: No such file or directory for /usr/share/info/gettext.info.gz
etc

I believe they are all solvable, but I would rather prefer 1611 where yum update does not update those base components.

@jperrin
Copy link
Collaborator

jperrin commented Dec 14, 2016

So, I've spent a couple days sorting out the 7.3.1611 base container (which should be arriving shortly)

This glibc behavior is consistent, though I don't fully understand why yet. With a brand new 7.3.1611 container, the locales are as expected. a 'yum reinstall glibc-common' reduces the available locales to POSIX and C, reliably.

@mark-adams
Copy link

I've experienced the same issue. Updating glibc-common eliminates the en-US.UTF-8 locale which causes problems for a lot of applications.

Running localdef as suggested above worked for me but it would be great if we could either determine why glib-common's installation is removing the locale and/or rebuild the image so that it includes a newer version of glibc with the locale prebuilt again.

@andremarianiello
Copy link

I also noticed that reinstalling glibc-common would blow away the locales. I noticed that changing the line in /etc/yum.conf

override_install_langs=en_US.UTF-8

to

override_install_langs=en_US.utf8

and then reinstalling glibc-common will produce a en_US.utf8 locale (seen by locale -a). I think this line sets the _install_langs macro in the glibc specfile, which is in turn passed to build-locale-archive --install-langs. Since this command takes a colon-separated list of locales, you can specify multiple locales to be installed (see build-locale-archive --help for more info). If you want all the locales, you can set this line to all, or just remove it completely because the default value of %{_install_langs} is all.

I think the provided setting in /etc/yum.conf should be changed unless this is an issue with build-locale-archive.

@rchibiscus
Copy link

encounter this issue also. the workaround I use is to unset LC_ALL environment variable before running my program in Dockerfile like:

ENV LC_ALL=

please fix it as soon as possible. Thanks!

@ewanmellor
Copy link

This seems to have been fixed in the latest images. I don't know for sure, but I'm guessing that it was the locale-handling changes in this changeset: CentOS/sig-cloud-instance-build@b74306a

@ninrod
Copy link

ninrod commented Feb 22, 2017

I was just hit by this and localedef -i en_US -f UTF-8 en_US.UTF-8 from @robinst's comment saved me.

@jperrin
Copy link
Collaborator

jperrin commented Mar 15, 2017

This should be resolved once the latest 7 base image is merged in, changed in docker-library/official-images#2750

@kristi
Copy link

kristi commented Mar 21, 2017

Looks like that PR is merged now.

farosas pushed a commit to farosas/sig-cloud-instance-build that referenced this issue Jun 5, 2017
farosas pushed a commit to farosas/sig-cloud-instance-build that referenced this issue Jun 5, 2017
@cdrage
Copy link

cdrage commented Jan 18, 2018

Since this was pushed here: https://github.com/docker-library/official-images/pull/2750/files could we close this issue?

@jperrin
Copy link
Collaborator

jperrin commented Jan 18, 2018

yup.

@davehowell
Copy link

I've had this issue on Centos 8 image, when I ran locale it showed LC_CTYPE empty and some errors like

locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory

I found running yum install glibc-langpack-en was the only way to fix it, as per this https://bugzilla.redhat.com/show_bug.cgi?id=1677927#c7

There is a comment that says

These files are deliberately deleted from the base install used to create the minimal image. This is done to make the overall image smaller.

@hrw
Copy link

hrw commented Oct 24, 2019

On AArch64 running "yum update glibc-common" from 2.17-260 to 2.17-292 removes every locale other than C and POSIX.

On x86-64 it ends in C, POSIX, en_US.utf8 being defined.

@zazazack
Copy link

zazazack commented Nov 2, 2019

Problem

ERROR: Failed to set locale, defaulting to C

Steps to reproduce

$ docker pull centos:latest
$ docker run -it centos
[root@docker]# uname -a
Linux 1698c6775409 4.9.184-linuxkit #1 SMP Tue Jul 2 22:58:16 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
[root@docker]# yum update -y && yum clean all. # per docker hub readme.md
[root@docker]# yum search python
Failed to set locale, defaulting to C  # ERROR
Last metadata expiration check: 0:09:02 ago on Sat Nov  2 17:57:53 2019.
Dependencies resolved.

Resolution

[root@docker]# yum -y install glibc-langpack-en.x86_64
[root@docker]# yum search python
Last metadata expiration check: 0:09:10 ago on Sat 02 Nov 2019 05:57:53 PM UTC.
Dependencies resolved.
Nothing to do.

@RCornish74
Copy link

@zazazack I get an error trying to install that package
No package glibc-langpack-en.x86_64 available.

carbonin added a commit to carbonin/manageiq-pods that referenced this issue Mar 2, 2020
Adding this package fixes warnings like these:

bash: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory
bash: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8)

As well as allows the monolithic image to initdb properly:

/etc/default/evm: line 26: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory
/etc/default/evm: line 26: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8)
== Checking MIQ database status ==
** DB has not been initialized
** Launching initdb
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

initdb: invalid locale settings; check LANG and LC_* environment variables
!! Failed to initdb

ref: CentOS/sig-cloud-instance-images#71
carbonin added a commit to carbonin/manageiq-pods that referenced this issue Mar 2, 2020
Adding this package fixes warnings like these:

bash: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory
bash: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8)

As well as allows the monolithic image to initdb properly:

/etc/default/evm: line 26: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory
/etc/default/evm: line 26: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8)
== Checking MIQ database status ==
** DB has not been initialized
** Launching initdb
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

initdb: invalid locale settings; check LANG and LC_* environment variables
!! Failed to initdb

ref: CentOS/sig-cloud-instance-images#71
@zhengyu88
Copy link

zhengyu88 commented Mar 18, 2020

Hi,

I am still seeing this problem when I use the centos:centos7 image:

$ docker run -it --rm centos:centos7 /bin/bash                    
[root@ab125c35c3cf /]# locale
LANG=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=

cinc-bot pushed a commit to cinc-project/docker-images that referenced this issue Aug 4, 2021
This works around CentOS/sig-cloud-instance-images#71

Signed-off-by: Lance Albertson <[email protected]>
@DesKonstantin
Copy link

For 'alt linux' way to fix it:

apt-get install glibc-locales glibc-timezones

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests