【问题标题】:Mac OS X 10.11 - Add Postgres to $PATH UnsuccessfulMac OS X 10.11 - 将 Postgres 添加到 $PATH 不成功
【发布时间】:2016-05-15 23:43:49
【问题描述】:

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

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

我按照here 的说明进行操作,但无法成功添加此行:

export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/bin

该文件夹实际上在我的计算机上包含“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'

我尝试将 Postgres 行添加到该文件的末尾,但它不起作用。网上搜索后,关于如何将PATH添加到.bash_profile似乎并没有达成共识。我尝试了许多列出的版本,但没有一个有效。

如果我做错了请告诉我!

【问题讨论】:

    标签: bash postgresql heroku psql .bash-profile


    【解决方案1】:

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

    export PATH=/Applications/Postgres.app/Contents/Versions/latest/bin:$PATH
    

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

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

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

    告诉我它是否有效。

    【讨论】:

    • 我浏览了这个问题的许多版本,这些版本有更详尽的回答和解释,但没有奏效。你的做到了,更重要的是,我明白为什么。感谢您简洁明了地解释。
    猜你喜欢
    • 2016-05-31
    • 2019-08-31
    • 2016-12-22
    • 1970-01-01
    • 2012-03-16
    • 2017-04-19
    • 2016-05-10
    • 1970-01-01
    • 2016-03-20
    相关资源
    最近更新 更多