Reputation: 1684
I'm trying to install ruby on rails on OSX for heroku, for which I used this tutorial. It seemed to install fine on the terminal, but after doing
$rails new myapp --database=postgresql
cd myapp
I did this
rails generate controller welcome
and got an error:
Could not find gem 'spring (>= 0) ruby' in the gems available on this machine.
Run
bundle installto install missing gems.
And after following the instructions, I got
'An error occurred while installing pg (0.17.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.17.1'` succeeds before bundling.'
And then...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
...
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.
A similar SO question said the problem was solved by updating XCode, but I don't think that's my problem. If it wasn't already apparent, I'm not very experienced with the terminal or ruby, so I'm not sure how I can approach this issue.
EDIT:
new error message
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/mahireusufzai/.rbenv/versions/2.1.1/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/local/bin/pg_config
*** 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.
...
/Users/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:541:in `try_link0'
from /Users/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:556:in `try_link'
from extconf.rb:39:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /Users/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/pg-0.17.1 for inspection.
Upvotes: 0
Views: 2107
Reputation: 11126
try
yum install postgresql-devel
or
brew install postgresql
then gem install pg
should work
Upvotes: 0
Reputation: 998
You need to install the postgresql development libraries first. It's complaining libpq-fe.h is missing.
Try to solve as per the answer in the following post: Rails: Error installing pg gem
Upvotes: 1