4

I am trying to add PostgreSQL to my $PATH variable. I tried this to see where psql is

whereis psql

To which I got a null response. I do have the PostgreSQL.app installed so I clicked on "Open psql" from the GUI and it prompted the Terminal to open and display:

 /Applications/Postgres.app/Contents/MacOS/bin/psql; exit;

So I tried to add the above to the $PATH variable in my ~/.bash_profile (which may have its own problems since I don't know if you can add paths with .app extensions to the $PATH) but when I restart my Terminal and do echo $PATH | grep Postgres.app I get nothin'.

0

2 Answers 2

4

Here's an approach to take help isolate problems you may have.

Step 1: See if you can add PostgreSQL to your PATH without using Bash dot files.

$ export PATH=/Applications/Postgres.app/Contents/MacOS/bin:$PATH;
$ which psql

If this works...

Step 2: Verify that ~\.bash_profile is being sourced when a new user session is started.

Add the following to the end of your ~/.bash_profile:

echo "From bash_profile.";

Now restart Terminal.app or iTerm and see if that message appears about your prompt.

If this works...

Step 3: Add PATH to ~/.bash_profile.

In ~/.bash_profile:

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

Restart your terminal and run:

$ which psql

If you're not seeing:

/Applications/Postgres.app/Contents/MacOS/bin/psql

Then it might be time to scrap trying to install PostgreSQL as a Mac package and use Homebrew.

NOTE: It's psql and NOT pgsql.

Sign up to request clarification or add additional context in comments.

12 Comments

do I need to restart Terminal in between setting the variable and the whereis command? Is there a command to reset Terminal that is more legit than just closing and opening Terminal.app?
No, don't restart the terminal in Step 1. After you run the export cmd, what does echo $PATH; return?
I think it's Homebrew time :). is it just brew install postgresql ?
Wish I could be of more help. The official install docs for Postgres.app are very similar to my answer postgresapp.com/documentation but I'm stumped. Good luck!
well in anyways the Homebrew approach works beautifully. thank you for all yr help!
|
1

From the Postgres documentation page:

sudo mkdir -p /etc/paths.d && echo /Applications/Postgres.app/Contents/Versions/latest/bin | sudo tee /etc/paths.d/postgresapp

restart your terminal and you will have it in your path.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.