Reputation: 4203
After I upgraded to Mavericks, PostgreSQL started playing up, giving this error message whenever I call pg_restore
without calling the full path:
pg_restore: command not found
If I specify the full path it works, but that's obvious not optimal:
/Applications/Postgres93.app/Contents/MacOS/bin/pg_restore --verbose --clean --no-acl --no-owner -h localhost -U steven -d db/testivate_development $file_path
To fix this problem, I have tried removing all versions of PostgreSQL (with Homebrew) and then installed Postgres.app. You can confirm this has worked like this:
$ sudo find / -name pg_restore
/Applications/Postgres93.app/Contents/MacOS/bin/pg_restore
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory
To add PostgreSQL to my path, I've tried adding each of the following lines to ~/.bash_profile
, ~/bashrc
and ~/.zshrc
, restarting after each attempt:
export PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
...as per the postgresapp.com documentation, and then...
export PATH="/Applications/Postgres93.app/Contents/MacOS/bin:$PATH"
...as per the comments below.
None of this has solved my problem.
Upvotes: 16
Views: 23210
Reputation: 191
on macOS High Sierra 10.13.2 and PostgreSQL 9.6 it works for me:
export PATH=$PATH:/Library/PostgreSQL/9.6/bin:$PATH
Upvotes: 0
Reputation: 574
On my macOS, Postgre 9.6 is installed in
/Library/PostgreSQL/9.6
Upvotes: 0
Reputation: 52516
On macOS Sierra 10.12.1 with PostgreSQL 9.6.0.0
/Applications/Postgres.app/Contents/MacOS/Postgres
Postgres
is binary file.
Upvotes: 0
Reputation: 1494
If you are using zsh, try this line in your .zshrc and then restart the terminal
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.4/bin
Upvotes: 7
Reputation: 321
You need to add the path in your bash_profile
nano ~/.bash_profile
Add this line (my postgres version is 9.1):
export PATH=$PATH:/Library/PostgreSQL/9.1/bin/
Upvotes: 3
Reputation: 547
I had this problem too, so instead of adding this to my path in .bash_profile:
export PATH="/Applications/Postgres93.app/Contents/MacOS/bin:$PATH"
which is what had been recommended, I added
export PATH="/Applications/Postgres.app/Contents/Versions/9.3/bin:$PATH"
instead. The '9.3' is replaced by your own version.
I verified it afterwards using
which psql
And it found my version, whereas before it reported nothing.
I then then created a test database with
createdb test
This worked like a charm.
Upvotes: 10
Reputation: 3795
The examples others are giving that do export PATH=...
should be the solution to your problem. Since it's not working, you're going to have to debug a problem with your shell that has nothing to do with PostgreSQL.
Firstly, do which pg_restore
to see if there is another file called pg_restore
in your path that is confusing things. which
will usually give no output rather than a helpful error if nothing is found, otherwise it will print the path of what it did found. You may find an old broken install of PostgreSQL in /usr/local/bin
, for example.
If that didn't work, try echo $PATH
from a new shell. Do you see the path to the PostgreSQL binary directory in there? If not, $PATH
is not being set in your shell dot-rc files. This would be the case if you added it to a file called ~/bashrc
since bash(1) actually read ~/.bashrc
. Note the extra dot! I suspect this is your actual problem.
If that turns out to not be the problem, you can (re)read the rc file into your current session with source ~/.bashrc
. Again, echo $PATH
If it still doesn't contain the path, the dot-rc file contains a bug and is not being executed as far as the part that updates $PATH
. You can do bash --verbose ~/.bashrc
to run it, and you'll see each command as it's being executed. The failing command should be the last one displayed. (Note that when you run a script with bash
, it will not set variables in your current shell.)
Upvotes: 5
Reputation: 47169
Try adding this line to your .bash_profile:
export PATH="/Applications/Postgres93.app/Contents/MacOS/bin:$PATH"
and remove or comment out the previous reference.
Upvotes: 11