【问题标题】:How do I get postgresql to work in my local environment? I want to build and deploy to heroku.如何让 postgresql 在我的本地环境中工作?我想构建并部署到heroku。
【发布时间】:2016-12-28 10:27:17
【问题描述】:

我在 El Capitan 10.11.6 上并使用 bash。 红宝石 2.3.0 轨道 5.0.0

我一直在学习 ruby​​/rails,并希望将应用程序推送到 heroku。我已按照heroku documentationPostgres.app 文档中列出的步骤进行操作。

我下载了 Postgres.app 并将其移至 Applications 目录。

我把它放在我的 ~/.bash_profile
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.5/bin

然而,当我输入$ which psql 时,我根本没有得到任何信息。此外,$ psql -h loclhost 什么也不做。但是,我可以通过双击图标“启动”Postgres.app,然后在菜单栏中找到大象。

此外,我无法安装gem 'pg'。我得到错误:

Installing pg 0.18.4 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory: /Users/jesselawson/.rvm/gems/ruby-2.3.0/gems/pg-       0.18.4/ext
/Users/jesselawson/.rvm/rubies/ruby-2.3.0/bin/ruby -r  ./siteconf20160821-1410-1o4aen1.rb extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
 --with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.    You may
need configuration options. 

An error occurred while installing pg (0.18.4), and Bundler cannot continue.
Make sure that gem install pg -v '0.18.4' succeeds before bundling.

【问题讨论】:

  • 您应该针对这些问题发布单独的问题。
  • 我的印象是它们可能与同一问题相关并提供更多上下文。 IE。 "这些错误发生在 x 设置不正确时"
  • 你试过用自制软件安装 postgres 吗?

标签: bash postgresql heroku ruby-on-rails-5 pg


【解决方案1】:

如您的错误消息中所述,您应该先尝试安装 gem,而不使用 bundler。

在您的控制台中尝试以下命令:

gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.5/bin/pg_config

如果您仍有问题,请尝试以下资源:

【讨论】:

    【解决方案2】:

    好的,在我发布问题后不久,我找到了答案。因为我下载并正在使用 Postgres.app,所以我必须通过双击图标来运行应用程序。然后在终端中我可以访问 cli。除非应用程序正在运行,否则无法与 pg 数据库交互。要在不运行应用程序的情况下访问,我必须通过自制软件安装。在这种情况下,它会概率。由于 user_name 问题,删除 Postgres.app 是有意义的,并尽量减少怪异的动作,以及我的普遍困惑。 (坚持一个或另一个)一旦我启动了 Postgres.app,我就可以运行 bundle install 和 gem 'pg' 安装就好了。谢谢大家的帮助! :)

    【讨论】:

      猜你喜欢
      • 2022-06-15
      • 2020-02-03
      • 1970-01-01
      • 2014-03-31
      • 1970-01-01
      • 2020-11-05
      • 1970-01-01
      • 2014-06-26
      • 2021-08-04
      相关资源
      最近更新 更多