cpursley
cpursley

Reputation: 182

PATH issue installing Postgres on OS X Lion: How do I edit Bash_Profile?

I'm trying to get Postgres up and running on OS X Lion - homebrew - rvm.

http://railscasts.com/episodes/342-migrating-to-postgresql

After following the above instructions, I ran into the same problem described here:

Repairing Postgresql after upgrading to OSX 10.7 Lion

Running which psql yields usr/bin/psql when it should be usr/local/bin/psql

Ok, I understand that I need to edit my bash file with export PATH=/usr/local/bin:$PATH

There's a ton of questions on here mentioning this is what I should do.

UPDATE

Here's what I tried:

I opened up the .bash_file this way:

open -e ~/.bash_profile

And modified it like this (this is all that is in the file):

export PATH="/usr/local/bin:$PATH"
[[ -s "/Users/chase/.rvm/scripts/rvm" ]] && source "/Users/chase/.rvm/scripts/rvm"

Running source ~/.bash_profile then which psql now yields usr/local/bin/psql

Which seems to have answered the main question.

However, when I go generate a new rails app with -d postgresql as the database, it works up until I try rake db:create:all which results in

could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

But I suppose that's for another question ; )

Postgres - could not connect to server after trying rake db:create:all

Upvotes: 0

Views: 478

Answers (2)

AndrejKolar
AndrejKolar

Reputation: 294

Your bash file is located in your home directory ~/.bash_profile. Use any editor to modify it.

You can enter nano ~/.bash_profile in the terminal if you don't have an editor set up, and it will open a simple editor in the terminal to enable you to edit the file. It will do the job, but everybody should really switch to a better editor.

There you have to change the order of the export PATH elements. Just put /usr/local/bin before /usr/bin so the shell will check the /usr/local/bin first.

Upvotes: 1

Dave Newton
Dave Newton

Reputation: 160321

Your .bash_profile file is in your home directory. If the file isn't there, just make one.

Terminal windows should open in your home directory. You can also get there by typing cd ~. Or open the file from a Finder window, but it'll be invisible unless you've selected to "Show Hidden Files".

As far as how to edit it, use whatever editor you're comfortable with, but make sure it can save actual text files (e.g., no rich text a la Word, OpenOffice, etc unless you export as plain text).

Upvotes: 2

Related Questions