Thread: Problem with locales on Linux with 9.3.4
Hi,
I'm running Pg 9.3.4 on Ubuntu Linux 12.04/Precise. Pg is installed from PGDG repo (http://apt.postgresql.org/pub/repos/apt/).It somehow got database created in locale that it can't now open:
$ psql
psql: FATAL: database locale is incompatible with operating system
DETAIL: The database was initialized with LC_COLLATE "en_GB.UTF-8", which is not recognized by setlocale().
HINT: Recreate the database with another locale or install the missing locale.
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------------+----------------+----------+-------------+-------------+-----------------------
xxxxxxxxxxxxxxx | xxxxxxxxxxxxxx | UTF8 | pl_PL.UTF-8 | pl_PL.UTF-8 |
postgres | postgres | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 |
template0 | postgres | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(4 rows)
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------------+----------------+----------+-------------+-------------+-----------------------
xxxxxxxxxxxxxxx | xxxxxxxxxxxxxx | UTF8 | pl_PL.UTF-8 | pl_PL.UTF-8 |
postgres | postgres | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 |
template0 | postgres | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(4 rows)
Locale settings in Pg:
# select name, setting from pg_settings where name ~ '^lc_';
name | setting
-------------+-------------
lc_collate | pl_PL.UTF-8
lc_ctype | pl_PL.UTF-8
lc_messages | en_US.UTF-8
lc_monetary | en_US.UTF-8
lc_numeric | en_US.UTF-8
lc_time | en_US.UTF-8
(6 rows)
# select name, setting from pg_settings where name ~ '^lc_';
name | setting
-------------+-------------
lc_collate | pl_PL.UTF-8
lc_ctype | pl_PL.UTF-8
lc_messages | en_US.UTF-8
lc_monetary | en_US.UTF-8
lc_numeric | en_US.UTF-8
lc_time | en_US.UTF-8
(6 rows)
The thing is that system knows about en_GB:
$ locale -a
C
cs_CZ.utf8
C.UTF-8
de_DE.utf8
en_GB
en_GB.iso88591
en_GB.iso885915
en_GB.utf8
en_US.utf8
pl_PL.utf8
POSIX
sk_SK.utf8
$ LC_ALL=en_GB.UTF-8 locale
LANG=en_GB.UTF-8
LANGUAGE=
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER="en_GB.UTF-8"
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT="en_GB.UTF-8"
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=en_GB.UTF-8
$ locale -a
C
cs_CZ.utf8
C.UTF-8
de_DE.utf8
en_GB
en_GB.iso88591
en_GB.iso885915
en_GB.utf8
en_US.utf8
pl_PL.utf8
POSIX
sk_SK.utf8
$ LC_ALL=en_GB.UTF-8 locale
LANG=en_GB.UTF-8
LANGUAGE=
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER="en_GB.UTF-8"
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT="en_GB.UTF-8"
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=en_GB.UTF-8
I straced Pg, and it showed:
17:18:42.386260 open("/usr/lib/locale/en_GB.UTF-8/LC_COLLATE", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) <0.000014> 17:18:42.386299 open("/usr/lib/locale/en_GB.utf8/LC_COLLATE", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) <0.000014> 17:18:42.386337 open("/usr/lib/locale/en_GB/LC_COLLATE", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) <0.000014> 17:18:42.386374 open("/usr/lib/locale/en.UTF-8/LC_COLLATE", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) <0.000016> 17:18:42.386418 open("/usr/lib/locale/en.utf8/LC_COLLATE", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) <0.000014> 17:18:42.386455 open("/usr/lib/locale/en/LC_COLLATE", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) <0.000015> 17:18:42.386492 open("/usr/share/locale-langpack/en_GB.UTF-8/LC_COLLATE", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) <0.000015> 17:18:42.386530 open("/usr/share/locale-langpack/en_GB.utf8/LC_COLLATE", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) <0.000013> 17:18:42.386562 open("/usr/share/locale-langpack/en_GB/LC_COLLATE", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) <0.000011> 17:18:42.386591 open("/usr/share/locale-langpack/en.UTF-8/LC_COLLATE", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) <0.000008> 17:18:42.386618 open("/usr/share/locale-langpack/en.utf8/LC_COLLATE", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) <0.000009> 17:18:42.386645 open("/usr/share/locale-langpack/en/LC_COLLATE", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) <0.000008> 17:18:42.386723 write(2, "2014-06-06 15:18:42 GMT FATAL: database locale is incompatible with operating system\n2014-06-06 15:18:42 GMT DETAIL: The database was initialized with LC_COLLATE \"en_GB.UTF-8\", which is not recognized by setlocale().\n2014-06-06 15:18:42 GMT HINT: Recre"..., 324) = 324 <0.000023>In /usr/lib/locale, I have only:
1. Directory C.UTF-8
2. File: locale-archive
It looks like if system locale was "packed" into this archive, but Pg for some reason cannot open it, and required locale files to be separately in subdirectories.
Is it possible? Anyone encountered something like this before? If so - what can be done? I didn't found any way to "unpack" the archive with locales.
depesz
depesz
On 06/06/2014 09:05 AM, hubert depesz lubaczewski wrote: > Hi, > I'm running Pg 9.3.4 on Ubuntu Linux 12.04/Precise. Pg is installed from > PGDG repo (http://apt.postgresql.org/pub/repos/apt/). > > It somehow got database created in locale that it can't now open: > > $ psql > psql: FATAL: database locale is incompatible with operating system > DETAIL: The database was initialized with LC_COLLATE "en_GB.UTF-8", > which is not recognized by setlocale(). > HINT: Recreate the database with another locale or install the missing > locale. > > > The thing is that system knows about en_GB: > > > Is it possible? Anyone encountered something like this before? If so - > what can be done? I didn't found any way to "unpack" the archive with > locales. Seems this is a new Ubuntu thing: http://manpages.ubuntu.com/manpages/precise/man8/locale-gen.8.html and an example: http://backdrift.org/fixing-no-such-file-or-directory-locale-errors > > depesz > > -- Adrian Klaver adrian.klaver@aklaver.com
locale-gen just regenerates the locale - which I have. It's just that PostgreSQL doesn't see it. When I run locale-gen, it just shows that all locales (listed by locale -a) are "up to date".
depesz
depesz
On Fri, Jun 6, 2014 at 10:04 PM, Adrian Klaver <adrian.klaver@aklaver.com> wrote:
On 06/06/2014 09:05 AM, hubert depesz lubaczewski wrote:Hi,
I'm running Pg 9.3.4 on Ubuntu Linux 12.04/Precise. Pg is installed from
PGDG repo (http://apt.postgresql.org/pub/repos/apt/).
It somehow got database created in locale that it can't now open:
$ psql
psql: FATAL: database locale is incompatible with operating system
DETAIL: The database was initialized with LC_COLLATE "en_GB.UTF-8",
which is not recognized by setlocale().
HINT: Recreate the database with another locale or install the missing
locale.The thing is that system knows about en_GB:Is it possible? Anyone encountered something like this before? If so -
what can be done? I didn't found any way to "unpack" the archive with
locales.
Seems this is a new Ubuntu thing:
http://manpages.ubuntu.com/manpages/precise/man8/locale-gen.8.html
and an example:
http://backdrift.org/fixing-no-such-file-or-directory-locale-errors
depesz
--
Adrian Klaver
adrian.klaver@aklaver.com
On 06/06/2014 04:36 PM, hubert depesz lubaczewski wrote: > locale-gen just regenerates the locale - which I have. It's just that > PostgreSQL doesn't see it. When I run locale-gen, it just shows that all > locales (listed by locale -a) are "up to date". Did you do 'dpkg-reconfigure locales' after the locale-gen? > > depesz > -- Adrian Klaver adrian.klaver@aklaver.com
On 06/06/2014 04:36 PM, hubert depesz lubaczewski wrote: > locale-gen just regenerates the locale - which I have. It's just that > PostgreSQL doesn't see it. When I run locale-gen, it just shows that all > locales (listed by locale -a) are "up to date". > On further reading another way would be to use the localedef command with the --no-archive option: http://manpages.ubuntu.com/manpages/precise/man1/localedef.1.html > depesz -- Adrian Klaver adrian.klaver@aklaver.com
localedef --no-archive, requires additional argument, and then it waits on something. I'm definitely not an locale expert, so I have no idea what it does. There is "locale-gen" option "--no-archive", too, but when I run "locale-gen --no-archive", I just get:
# locale-gen --no-archive
Generating locales...
cs_CZ.UTF-8... up-to-date
de_DE.UTF-8... up-to-date
en_GB.ISO-8859-1... up-to-date
en_GB.ISO-8859-15... up-to-date
en_GB.UTF-8... up-to-date
en_US.UTF-8... up-to-date
pl_PL.UTF-8... up-to-date
sk_SK.UTF-8... up-to-date
Generation complete.
And nothing changes.# locale-gen --no-archive
Generating locales...
cs_CZ.UTF-8... up-to-date
de_DE.UTF-8... up-to-date
en_GB.ISO-8859-1... up-to-date
en_GB.ISO-8859-15... up-to-date
en_GB.UTF-8... up-to-date
en_US.UTF-8... up-to-date
pl_PL.UTF-8... up-to-date
sk_SK.UTF-8... up-to-date
Generation complete.
On Sat, Jun 7, 2014 at 2:23 AM, Adrian Klaver <adrian.klaver@aklaver.com> wrote:
On 06/06/2014 04:36 PM, hubert depesz lubaczewski wrote:On further reading another way would be to use the localedef command with the --no-archive option:locale-gen just regenerates the locale - which I have. It's just that
PostgreSQL doesn't see it. When I run locale-gen, it just shows that all
locales (listed by locale -a) are "up to date".
http://manpages.ubuntu.com/manpages/precise/man1/localedef.1.html
On 06/07/2014 08:17 AM, hubert depesz lubaczewski wrote: > localedef --no-archive, requires additional argument, and then it waits > on something. I'm definitely not an locale expert, so I have no idea > what it does. There is "locale-gen" option "--no-archive", too, but when > I run "locale-gen --no-archive", I just get: > > # locale-gen --no-archive > Generating locales... > cs_CZ.UTF-8... up-to-date > de_DE.UTF-8... up-to-date > en_GB.ISO-8859-1... up-to-date > en_GB.ISO-8859-15... up-to-date > en_GB.UTF-8... up-to-date > en_US.UTF-8... up-to-date > pl_PL.UTF-8... up-to-date > sk_SK.UTF-8... up-to-date > Generation complete. > > And nothing changes. From here: http://manpages.ubuntu.com/manpages/precise/en/man8/locale-gen.8.html If a list of languages and/or locales is specified as arguments, then locale-gen only generates these particular locales and adds the new ones to /var/lib/locales/supported.d/local. Otherwise it generates all supported locales. So this is the first step. The second is to do: sudo dpkg-reconfigure locales > > depesz > -- Adrian Klaver adrian.klaver@aklaver.com
On 06/07/2014 08:17 AM, hubert depesz lubaczewski wrote: > localedef --no-archive, requires additional argument, and then it waits > on something. I'm definitely not an locale expert, so I have no idea > what it does. There is "locale-gen" option "--no-archive", too, but when > I run "locale-gen --no-archive", I just get: > > # locale-gen --no-archive > Generating locales... > cs_CZ.UTF-8... up-to-date > de_DE.UTF-8... up-to-date > en_GB.ISO-8859-1... up-to-date > en_GB.ISO-8859-15... up-to-date > en_GB.UTF-8... up-to-date > en_US.UTF-8... up-to-date > pl_PL.UTF-8... up-to-date > sk_SK.UTF-8... up-to-date > Generation complete. > > And nothing changes. Should have been clearer on my previous post, the dpkg command is for use after locale-gen. Missed the part where you ran localedef until I reread the post. localedef is looking for the following, from example in man page: EXAMPLES Compile the locale files for Finnish in the UTF-8 character set and add it to the default locale archive with the name fi_FI.UTF-8: localedef -f UTF-8 -i fi_FI fi_FI.UTF-8 Where: localedef [options] outputpath and outpath with --no-archive is by default /usr/lib/locale otherwise outpath is /usr/lib/locale/locale-archive > > depesz > -- Adrian Klaver adrian.klaver@aklaver.com
Seems I now have the locale. Too bad I had to delete the "bad" databases earlier.
Thanks Adrian,
depeszThanks Adrian,
On Sat, Jun 7, 2014 at 7:16 PM, Adrian Klaver <adrian.klaver@aklaver.com> wrote:
On 06/07/2014 08:17 AM, hubert depesz lubaczewski wrote:Should have been clearer on my previous post, the dpkg command is for use after locale-gen.localedef --no-archive, requires additional argument, and then it waits
on something. I'm definitely not an locale expert, so I have no idea
what it does. There is "locale-gen" option "--no-archive", too, but when
I run "locale-gen --no-archive", I just get:
# locale-gen --no-archive
Generating locales...
cs_CZ.UTF-8... up-to-date
de_DE.UTF-8... up-to-date
en_GB.ISO-8859-1... up-to-date
en_GB.ISO-8859-15... up-to-date
en_GB.UTF-8... up-to-date
en_US.UTF-8... up-to-date
pl_PL.UTF-8... up-to-date
sk_SK.UTF-8... up-to-date
Generation complete.
And nothing changes.
Missed the part where you ran localedef until I reread the post. localedef is looking for the following, from example in man page:
EXAMPLES
Compile the locale files for Finnish in the UTF-8 character set and add
it to the default locale archive with the name fi_FI.UTF-8:
localedef -f UTF-8 -i fi_FI fi_FI.UTF-8
Where:
localedef [options] outputpath
and outpath with --no-archive is by default /usr/lib/locale
otherwise outpath is /usr/lib/locale/locale-archive
On 06/07/2014 12:43 PM, hubert depesz lubaczewski wrote: > Seems I now have the locale. Too bad I had to delete the "bad" databases > earlier. So, just for completeness what worked: locale-gen sudo dpkg-reconfigure locales or localedef ? > > Thanks Adrian, > > depesz > > > -- Adrian Klaver adrian.klaver@aklaver.com
localedef.
depesz
depesz
On Sat, Jun 7, 2014 at 9:57 PM, Adrian Klaver <adrian.klaver@aklaver.com> wrote:
On 06/07/2014 12:43 PM, hubert depesz lubaczewski wrote:So, just for completeness what worked:Seems I now have the locale. Too bad I had to delete the "bad" databases
earlier.
locale-gen
sudo dpkg-reconfigure locales
or
localedef ?
Thanks Adrian,
depesz
--
Adrian Klaver
adrian.klaver@aklaver.com