2

I'm getting the following error whenever I run rake tasks on my Rails app's database.

pg_dump: server version: 9.2.4; pg_dump version: 9.1.5
pg_dump: aborting because of server version mismatch

I've Googled around, and found some suggestions about updating the postgres brew package, but this did not work.

Why is the incorrect pg_dump version being used, and how can I fix this? Or what search terms should I be looking for to find a solution?

EDIT

Info on my pg_dump configuration:

$ pg_dump --version
> pg_dump (PostgreSQL) 9.1.5
$ which pg_dump
> /usr/bin/pg_dump
$ echo $PATH
> /Users/andrewharvey/.rvm/gems/ruby-1.9.3-p392@mantawatch/bin:/Users/andrewharvey/.rvm/gems/ruby-1.9.3-p392@global/bin:/Users/andrewharvey/.rvm/rubies/ruby-1.9.3-p392/bin:/Users/andrewharvey/.rvm/bin:/usr/local/heroku/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/andrewharvey/.rvm/bin

I'm using oh_my_zsh, and path is defined in my .zshrc file. This may be the cause of my problem (and I'm sure this can be cleaned up), unfortunately I don't know enough what I'm doing to debug and edit this. Grateful for pointers (I'm using RVM and postgres installed via Homebrew).

source $ZSH/oh-my-zsh.sh

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"

alias pg='pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log'

export
 PATH=$PATH:/usr/local/bin:/Users/andrewharvey/.rvm/gems/ruby-2.0.0-p0/bin:/Users/andrewharvey/.rvm/gems/ruby-2.0.0-p0@global/bin:/Users/andrewharvey/.rvm/rubies/ruby-2.0.0-p0/bin:/Users/andrewharvey/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
Andy Harvey
  • 12,333
  • 17
  • 93
  • 185

2 Answers2

5

For mac users put to the top of .profile file.

export PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"

then run

. ~/.profile
Andrey Yasinishyn
  • 1,851
  • 2
  • 23
  • 36
3

What does the output of the following show? It looks like the pg_dump version you are trying to use is a 9.1 version, whereas the cluster you are connecting to is 9.2. If that's the case, then you'll need to determine the correct path of the 9.2 pg_dump.

pg_dump --version

which pg_dump

echo $PATH

[edited after OP provided more details]

According to this page: https://wiki.postgresql.org/wiki/Installers/Mac_OS_X, homebrew probably installed the tools at /usr/local/bin. However, your current $PATH has /usr/local/bin located after several other paths. I've tidied up your $PATH setting. so try saving the changes below to your .zshrc file and source'ing it to pick up the changes (source ~/.zshrc).

export PATH=/usr/local/bin:/Users/andrewharvey/.rvm/gems/ruby-2.0.0-p0/bin:/Users/andrewharvey/.rvm/gems/ruby-2.0.0-p0@global/bin:/Users/andrewharvey/.rvm/rubies/ruby-2.0.0-p0/bin:/Users/andrewharvey/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:$PATH
export PATH="/usr/local/heroku/bin:$PATH"
bma
  • 9,424
  • 2
  • 33
  • 22
  • hi bma, I've added the outputs to my question above. I have a feeling that $path may be the issue, as the entries is my .zshrc file are looking quite messy. Unfortunately I'm not yet confident enough in my understanding to debug and edit this (I've added the relevant bits to my question). BTW, I've installed postgres from homebrew, if this is relevant. – Andy Harvey Jul 22 '13 at 10:27