问题
I just installed Postgres.app, and now which psql
returns nothing. I followed the instructions listed on the Postgres site; here's what I did:
1) Dragged my old version of Postgres to the trash. Emptied trash.
2) Downloaded the current version of Postgres.app. Dragged it to Applications folder.
3) Restarted Terminal.
The output I'm looking for from which psql
is something like: /Applications/Postgres.app/Contents/Versions/9.3/bin/psql
When I run brew install postgresql
followed by which psql
, I get /usr/local/bin/psql
. Which is at least something, but it's not what I want.
In case it's useful, here's my .bashrc:
if [ -f ~/.bash_profile ]; then
source ~/.bash_profile
fi
PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
export DYLD_LIBRARY_PATH="/Applications/Postgres.app/Contents/MacOS/lib:$DYLD_LIBRARY_PATH"
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
rvm get stable --auto-dotfiles
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
And my .bash_profile:
export PATH=/usr/local/bin:$PATH
export PATH=/usr/local/share/python:$PATH
# Python
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python2.7
export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages'
export PIP_VIRTUALENV_BASE=$WORKON_HOME
export PIP_RESPECT_VIRTUALENV=true
if [[ -r /usr/local/share/python/virtualenvwrapper.sh ]]; then
source /usr/local/share/python/virtualenvwrapper.sh
else
echo "WARNING: Can't find virtualenvwrapper.sh"
fi
export PS1="\h:\w \u\$ "
# for git
LESS="-qrX -P %lt"
export LESS
# colorize shell output
export CLICOLOR=1
export LSCOLORS=Hxfxcxdxbxegedabagacad
#========== ALIASES ===========
alias u="cd .."
alias uu="cd ../.."
alias uuu="cd ../../.."
alias cd..="cd .."
alias rm="rm -i"
alias ll="ls -laFGh"
alias ls="ls -FGh"
alias new="ls -lat | head -15"
# node needs to not have DYLD_LIBRARY_PATH set
alias node="DYLD_LIBRARY_PATH=''; node"
# postgres stuff
PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
export DYLD_LIBRARY_PATH="/Applications/Postgres.app/Contents/MacOS/lib:$DYLD_LIBRARY_PATH"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
Many thanks!
回答1:
A solution! For posterity, here's what worked for me:
1) add the line export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.4/bin
to .bash_profile. For further reading, I found this solution on the Postgres.app Command Line Tools page.
2) run brew uninstall postgresql
. This seems suboptimal, as I'll almost certainly want it later, but before uninstalling, the path to the brew-installed postgresql is all I got when I ran which psql
.
来源:https://stackoverflow.com/questions/29932347/postgres-app-setup-getting-which-psql-to-return-desired-path