[英]How do I get postgresql to work in my local environment? I want to build and deploy to heroku.
我在El Capitan 10.11.6上使用bash。 红宝石2.3.0导轨5.0.0
我一直在学习ruby / rails,想将一个应用程序推向heroku。 我已按照heroku文档和Postgres.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.
如错误消息中所述,您应该首先尝试安装gem,而不使用捆绑程序。
在控制台中尝试以下命令:
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.5/bin/pg_config
如果仍然有troube,请尝试以下资源:
好的,在我发布问题后不久,我找到了答案。 因为我已经下载并且正在使用Postgres.app,所以我必须双击该图标来运行该应用程序。 然后,在终端中,我可以访问cli。 除非应用程序正在运行,否则无法与pg数据库进行交互。 要在不运行应用程序的情况下获得访问权限,我必须通过自制软件进行安装。 在这种情况下,它可能会出现。 由于user_name问题而删除Postgres.app,并最大程度地减少怪异的动作以及我的一般困惑是很有意义的。 (坚持使用另一种方法)启动Postgres.app之后,我还可以运行bundle install并安装好gem 'pg'
。 谢谢大家的帮助! :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.