Last Updated: February 25, 2016
·
834
· dorianx

Fix Postgres after installing Yosemite

If you recently updated your mac to run Yosemite and you've been using Postgres for your development needs you may find that the Postgres daemon is no longer running and cannot be started.

You will see the following error:

$ postgres -D /usr/local/var/postgres
FATAL:  could not open directory "pg_tblspc": No such file or directory

It appears that Yosemite deleted a few folders.

To fix this you have a couple of options:

  1. Create the folders and put a .keep file in them so that they are not erased again. You can do this by running the following commands:
$ mkdir -p /usr/local/var/postgres/{pg_tblspc,pg_twophase,pg_stat_tmp}/
$ touch /usr/local/var/postgres/{pg_tblspc,pg_twophase,pg_stat_tmp}/.keep
  1. If you don't have any important data stored on your local Postgres instance, try running
$ rm -r /usr/local/var/postgres
$ initdb -D /usr/local/var/postgres

Note that this approach will drop all existing databases and you may have to re-run your rake tasks (reset, seed) to recreate them.