Don P
Don P

Reputation: 63728

Heroku pg:pull is giving sh: createdb: command not found

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)?

Upvotes: 5

Views: 3302

Answers (3)

dB'
dB'

Reputation: 8330

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

Upvotes: 14

Eric N
Eric N

Reputation: 2206

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.

Upvotes: 1

Alex
Alex

Reputation: 8539

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.

Upvotes: 2

Related Questions