Reputation: 113
I am on El Capitan 10.11.6 and using bash. ruby 2.3.0 rails 5.0.0
I have been learning ruby/rails and would like to push an app up to heroku. I have followed the steps outlined by the heroku documentation and Postgres.app documentation.
I downloaded Postgres.app and moved it to the Applications directory.
I placed this in my ~/.bash_profile
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.5/bin
Yet when I type in $ which psql
I get no info at all. Also, $ psql -h loclhost
does nothing. I can however, "start" Postgres.app by double clicking on the icon, and I get the elephant in the menu bar.
Furthermore, I can not install gem 'pg'
. I get the error:
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.
and
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.
Upvotes: 0
Views: 78
Reputation: 113
Ok so shortly after I posted the question, I found the answer. Because I downloaded and am using the Postgres.app, I have to have to app running by double clicking the icon. Then in the terminal I can access the cli. Interacting with the pg database can not be done unless the app is running. To have access without the app running I would have to install via homebrew. In which case it would prob. make sense to remove the Postgres.app due to user_name issues, and to minimize spooky action, and my general confusion. (stick with one or the other) Once I started the Postgres.app I could then also run bundle install and gem 'pg'
installed just fine. Thank you all for all the help! :)
Upvotes: 0
Reputation: 6377
As stated in your error message, you should try to install the gem first, without the use of bundler.
Try the following command in your console:
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.5/bin/pg_config
In case you still have troube, try the following resources:
Upvotes: 1