简体   繁体   English

Postgres.app设置:获取`哪个psql`返回所需的路径

[英]Postgres.app setup: getting `which psql` to return desired path

I just installed Postgres.app, and now which psql returns nothing . 我刚刚安装了Postgres.app,现在which psql什么也没有返回 I followed the instructions listed on the Postgres site ; 我按照Postgres网站上列出说明进行操作 ; here's what I did: 这就是我做的:

1) Dragged my old version of Postgres to the trash. 1)将旧版Postgres拖到垃圾箱。 Emptied trash. 清空垃圾。

2) Downloaded the current version of Postgres.app. 2)下载了当前版本的Postgres.app。 Dragged it to Applications folder. 将其拖动到Applications文件夹。

3) Restarted Terminal. 3)重启终端。

The output I'm looking for from which psql is something like: /Applications/Postgres.app/Contents/Versions/9.3/bin/psql 我正在寻找的输出, which psql是这样的: /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 . 当我运行brew install postgresql后跟which psql ,我得到/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: 如果它有用,这是我的.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: 而我的.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! 非常感谢!

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. 1)将行export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.4/bin到.bash_profile。 For further reading, I found this solution on the Postgres.app Command Line Tools page . 为了进一步阅读,我在Postgres.app命令行工具页面上找到了这个解决方案。

2) run brew uninstall postgresql . 2)运行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 . 这似乎不是最理想的,因为我几乎肯定会在以后想要它,但在卸载之前,brew我安装的postgresql的路径就是我运行which psql时得到的全部which psql

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM