Mac OS X 10.11-将Postgres添加到$ PATH不成功

sea*_*ean 0 postgresql bash heroku .bash-profile psql

我正在尝试安装Postgres以使用Heroku。

我按照Heroku教程中的说明进行操作,并且在安装Postgres之后(成功),它说要配置.bash_profile以允许Postgres命令行功能。

我正在按照此处的说明进行操作,但是无法成功添加以下行:

export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/bin
Run Code Online (Sandbox Code Playgroud)

该文件夹实际上在我的计算机上确实包含“ psql”,因此它应该可以工作。这是我当前的.bash_profile:

# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH

# The next line updates PATH for the Google Cloud SDK.
source '/Users/user/google-cloud-sdk/path.bash.inc'

# The next line enables shell command completion for gcloud.
source '/Users/user/google-cloud-sdk/completion.bash.inc'
Run Code Online (Sandbox Code Playgroud)

我试图将Postgres行添加到该文件的末尾,但是它不起作用。在线搜索之后,关于如何向.bash_profile中添加PATH似乎尚未达成共识。我尝试了列出的许多版本,但没有一个起作用。

如果我做错了,请告诉我!

Gho*_*ost 5

将此行添加到您的末尾.bash_profile

export PATH=/Applications/Postgres.app/Contents/Versions/latest/bin:$PATH
Run Code Online (Sandbox Code Playgroud)

这使得搜索二进制文件可以在“其余路径之前”在该位置查找

杀死终端的所有实例,然后再次打开它,它应该可以工作。

尝试which xxx在xxx是/Applications/Postgres.app/Contents/Versions/latest/bin中某个二进制文件的名称的位置,并检查它是否返回该位置。

告诉我是否可行。

  • 我浏览了这个问题的很多版本,这些版本有更详细的回答和解释,但没有用。你做到了,更重要的是,我明白为什么。感谢您简洁明了地解释。 (2认同)