Last Updated: February 25, 2016
·
3.125K
· jcuervo

Upgrading Postgres.app 9.3 to 9.4 on Yosemite OSX 10.10

After upgrading to Yosemite OSX 10.10, I decided to upgrade my local Postgres.app from 9.3 to 9.4. While following the upgrade instructions from the Postgress.app page, I ended up using the pg_upgrade command with the following options:

pg_upgrade \
 -b /Applications/Postgres.app/Contents/Versions/9.3/bin \
 -B /Applications/Postgres.app/Contents/Versions/9.4/bin\
 -d /Users/whoami/Library/Application\ Support/Postgres/var-9.3\
 -D /Users/whoami/Library/Application\ Support/Postgres/var-9.4\
 -j 3

NOTE: use whoami command and replace the whoami value on the command above specific to your local user.

With this command I encountered the following errors:
encoding cluster values do not match: old "UTF8", new "SQL_ASCII"
and
lc_collate cluster values do not match: old "C", new "en_US.UTF-8" Failure, exiting
To go around this issues:
1. Remove (delete) the new cluster directory. From my example it's the /Users/whoami/Library/Application\ Support/Postgres/var-9.4
2. Use initdb to make a prestine database: initdb --locale=C /Users/whoami/Library/Application\ Support/Postgres/var-9.4 -E utf8

Note the --locale=C and the -E utf8
3. run the pg_upgrade command again (see above)

Make sure that you got the your $PATH configured and pointed to the new version. From here, you can do a gem install pg smoothly or bump your Gemfile to the latest pg version.