Note that there are some explanatory texts on larger screens.

plurals
  1. POChef ENV settings not working
    primarykey
    data
    text
    <p>I am attempting to set up postgresql on a Vagrant box using Chef solo and am running into some problems. I need the default postgres encoding/locale to be UTF8. By default, the locale of the precise64 Ubuntu box is set to "C" so postgres is using LATIN1 for encoding. This is what I've done so far:</p> <p>I have a chef recipe that sets the locale by doing the following:</p> <pre><code>template "/etc/profile.d/lang.sh" do source "lang.sh.erb" mode "0644" end execute "locale-gen" do command "locale-gen en_US.UTF-8" end execute "dpkg-reconfigure-locales" do command "dpkg-reconfigure locales" end </code></pre> <p>where lang.sh.erb looks like:</p> <pre><code>export LANGUAGE="en_US.UTF-8" export LANG="en_US.UTF-8" export LC_ALL="en_US.UTF-8" </code></pre> <p>This sets up the locale correctly, but unfortunately it doesn't modify the current environment. So I have another recipe that just sets the ENV before including postgresql</p> <pre><code>ENV["LANGUAGE"] = ENV["LANG"] = ENV["LC_ALL"] = "en_US.UTF-8" include_recipe "postgresql::server" </code></pre> <p>This has no effect. The locale is set up correctly:</p> <pre><code>postgres@precise64:~$ locale LANG=en_US.UTF-8 LANGUAGE=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=en_US.UTF-8 </code></pre> <p>But postgres used the "C" locale when it was installed.</p> <pre><code>postgres@precise64:~$ psql -l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+---------+-------+----------------------- postgres | postgres | LATIN1 | en_US | en_US | template0 | postgres | LATIN1 | en_US | en_US | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | LATIN1 | en_US | en_US | =c/postgres + | | | | | postgres=CTc/postgres (3 rows) </code></pre> <p>For attribution's sake, I got all this from <a href="http://www.softr.li/blog/2012/05/22/chef-recipe-to-install-a-postgresql-server-on-a-machine-configured-with-en_us-locales" rel="nofollow">http://www.softr.li/blog/2012/05/22/chef-recipe-to-install-a-postgresql-server-on-a-machine-configured-with-en_us-locales</a>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload