5

When I try to do heroku pg:pull DATABASE_URL myappspassword, I get this error:

my-computer:a-folder (master*) · heroku pg:pull DATABASE_URL myappspassword
 !    sh: createdb: command not found
 !    
 !    Unable to create new local database. Ensure your local Postgres is working and try again.

For once Googling doesn't return a result. I'm wondering if it's related to the fact that when I do which psql, there is no result. Maybe I need to do something special with pgAdmin to get this working (e.g. export command line tools)?

Don P
  • 60,113
  • 114
  • 300
  • 432

3 Answers3

14

Are you on a Mac, by chance, and using Postgres App?

If so, the problem might be that createdb isn't on your path. Try adding it by inserting the following into ~/.bash_profile.

export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.4/bin

Then run source ~/.bash_profile and try again.

There's more info on the Postgres App site: http://postgresapp.com/documentation/cli-tools.html

dB'
  • 7,838
  • 15
  • 58
  • 101
  • 1
    Perfect! And [here is how to modify `~/.bash_profile`](http://stackoverflow.com/a/30462883/5802289). Note that the version number might have to be adapted depending on the local version installed. Obvious, but I missed it at first. – J0ANMM Jan 25 '17 at 19:33
2

Your instincts are correct. You need to be able to access the Postgres from your command line. pg:pull is attempting to create a new local database and drop the relevant data from your Heroku database into it. From the docs:

This command will create a new local database named “mylocaldb” and then pull data from database at DATABASE_URL...

Basically, your local machine is trying to run createdb locally but your terminal isn't recognizing it.

Alex
  • 8,321
  • 1
  • 34
  • 30
1

I battled this damn error for a few hours. I can't say for certain if this will work for everyone but I found my issue stemmed from running the command via iTerm/ZSH instead of just normal bash. I opened up plain-old vanilla terminal, ran the command, and everything fired off like it should.

Eric N
  • 2,136
  • 13
  • 13