I am not sure what happened - I know Postgres was working right after the upgrade to Lion, but it is not working anymore. I have Xcode 4 installed.
error:
$ gem install pg -- --with-pg-config=/usr/bin/pg_config
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/Users/Me/.rvm/rubies/ruby-1.9.2-p318/bin/ruby extconf.rb --with-pg-config=/usr/bin/pg_config
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... *** 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.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/Me/.rvm/rubies/ruby-1.9.2-p318/bin/ruby
--with-pg
--without-pg
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
--with-pg-config
/Users/Me/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/mkmf.rb:368:in `try_do': The complier failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/Me/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/mkmf.rb:452:in `try_cpp'
from /Users/Me/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/mkmf.rb:853:in `block in find_header'
from /Users/Me/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/mkmf.rb:693:in `block in checking_for'
from /Users/Me/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/mkmf.rb:280:in `block (2 levels) in postpone'
from /Users/Me/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/Me/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/mkmf.rb:280:in `block in postpone'
from /Users/Me/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/Me/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/mkmf.rb:276:in `postpone'
from /Users/Me/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/mkmf.rb:692:in `checking_for'
from /Users/Me/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/mkmf.rb:852:in `find_header'
from extconf.rb:40:in `<main>'
Gem files will remain installed in /Users/Me/.rvm/gems/ruby-1.9.2-p318/gems/pg-0.13.2 for inspection.
Results logged to /Users/Me/.rvm/gems/ruby-1.9.2-p318/gems/pg-0.13.2/ext/gem_make.out
EDIT*** I tried installing postgres via homebrew and got the following errors:
Warning: You have no /usr/bin/cc.
This means you probably can't build *anything*. You need to install the Command
Line Tools for Xcode. You can either download this from http://connect.apple.com
or install them from inside Xcode's Download preferences. Homebrew does not
require all of Xcode! You only need the Command Line Tools package!
Warning: Setting DYLD_LIBRARY_PATH can break dynamic linking.
You should probably unset it.
Warning: Your Homebrew is outdated
You haven't updated for at least 24 hours, this is a long time in brewland!
Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected dylibs:
/usr/local/lib/libruby.1.8.7.dylib
Warning: Unbrewed static libraries were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected static libraries:
/usr/local/lib/libruby-static.a
Warning: Your compilers are different from the standard versions for your Xcode.
If you have Xcode 4.3 or newer, you should install the Command Line Tools for
Xcode from within Xcode's Download preferences.
Otherwise, you should reinstall Xcode.
Warning: /usr/bin occurs before /usr/local/bin
This means that system-provided programs will be used instead of those
provided by Homebrew. The following tools exist at both paths:
bundle
edit_json.rb
erb
erubis
gem
irb
prettify_json.rb
rails
rake
rake2thor
rdoc
ri
ruby
testrb
thor
tt
update_rubygems
Consider amending your PATH so that /usr/local/bin
is ahead of /usr/bin in your PATH.
Warning: Your Xcode is configured with an invalid path.
You should change it to the correct path. Please note that there is no correct
path at this time if you have *only* installed the Command Line Tools for Xcode.
If your Xcode is pre-4.3 or you installed the whole of Xcode 4.3 then one of
these is (probably) what you want:
sudo xcode-select -switch /Developer
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
Trying forcing pg gem to build with the 64 bit libpg version.
ARCHFLAGS='-arch x86_64' gem install pg
Check out the following blog post: Using MySQL and Postgres on Mac OS X (Tiger) with RoR
Related
I've been trying to get rails working but whatever I do it comes up with this error. So far I've tried to update everything, re install homebrew, and re install ruby. RVM however will not installl
sudo gem install rails
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking if the C compiler accepts ... *** 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.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
--help
--clean
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:434:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:549:in `block in try_compile'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:500:in `with_werror'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:549:in `try_compile'
from extconf.rb:77:in `block in add_cflags'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:599:in `with_cflags'
from extconf.rb:76:in `add_cflags'
from extconf.rb:323:in `<main>'
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.5 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.5/ext/nokogiri/gem_make.out
Here you got the error
"You have to install development tools first."
Incase, while trying to update a bundle, you get an error "You have to install development tools first." on OSX ,
If you already have Xcode installed, you can still manually install the development tools via terminal:
xcode-select --install
Your problem will be solved.
Your question fails to specify your development environment. Mac? If so, Have you installed the full XCode from Apple? I see that line that says "install development tools"
Just a follow up ... to help explain
it may be that you are on a mac and rails cannot find the right compiler for c headers.
just install xcode from apps store / homebrew or go to terminal ...
$ xcode-select --install
complete the installation and agree on the licensing etc, then ...
$ sudo gem install rails
The last two days I am fighting with configuration of ImageMagick and rmagick gem. I found several topics on SO, but none of them helped me out with this issue.
Recently, I've tried update also rvm, but it didn't help me neither. When I run now bundle update, the output is:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/adam/.rvm/rubies/ruby-2.0.0-p353/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for /usr/bin/clang... yes
checking for Magick-config... yes
Warning: Found more than one ImageMagick installation. This could cause problems at runtime.
/usr/local/bin/Magick-config reports version 6.8.6 Q8 is installed in /usr/local
/opt/ImageMagick/bin/Magick-config reports version 6.8.8 Q16 is installed in /opt/ImageMagick
Using 6.8.6 Q8 from /usr/local.
checking for ImageMagick version >= 6.4.9... yes
checking for HDRI disabled version of ImageMagick... yes
checking for stdint.h... *** 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.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/adam/.rvm/rubies/ruby-2.0.0-p353/bin/ruby
/Users/adam/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:434:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/adam/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:565:in `try_cpp'
from /Users/adam/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:1044:in `block in have_header'
from /Users/adam/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:895:in `block in checking_for'
from /Users/adam/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:340:in `block (2 levels) in postpone'
from /Users/adam/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:310:in `open'
from /Users/adam/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:340:in `block in postpone'
from /Users/adam/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:310:in `open'
from /Users/adam/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:336:in `postpone'
from /Users/adam/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:894:in `checking_for'
from /Users/adam/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/mkmf.rb:1043:in `have_header'
from extconf.rb:194:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /Users/adam/.rvm/gems/ruby-2.0.0-p353/gems/rmagick-2.13.2 for inspection.
Results logged to /Users/adam/.rvm/gems/ruby-2.0.0-p353/extensions/x86_64-darwin-13/2.0.0/rmagick-2.13.2/gem_make.out
An error occurred while installing rmagick (2.13.2), and Bundler cannot continue.
Make sure that `gem install rmagick -v '2.13.2'` succeeds before bundling.
How to proceed now - which ImageMagick to remove? Or, is there something else what am I overlooking?
The error hints at the problem:
Warning: Found more than one ImageMagick installation. This could
cause problems at runtime.
/usr/local/bin/Magick-config reports version 6.8.6 Q8 is installed in /usr/local
/opt/ImageMagick/bin/Magick-config reports version 6.8.8 Q16 is installed in /opt/ImageMagick Using 6.8.6 Q8 from /usr/local.
And also:
You have to install development tools first.
You can do this by entering the command xcode-select --install and clicking Install
This installs gcc among other things you need to compile ImageMagick and other sources.
Now remove one of your current installations of ImageMagick. Or remove both and install ImageMagick with homebrew:
brew update
brew install imagemagick
If that doesn't work here's some links I found that might help:
ImageMagick Installer: http://cactuslab.com/imagemagick/
Link
I am new to rails and attempting to switch my default DB to Postgres from SQLite3. I have encountered an error. I am using gem install pg and getting this error error: Error installing pg: ERROR: Failed to build gem native extension. I am using Mavericks OSX and Ruby 1.9.3, Rails 3.2.12, and PG 9.3 –The goal is to deploy a sample app to heroku (which doesnt seem to support SQLite.
Steps I have tried:
link 1: Installing PG gem on OS X - failure to build native extension
link 2(heroku instructions): https://devcenter.heroku.com/articles/sqlite3
EDITED TO INCLUDE SPECIFIC ERROR MESSAGE BELOW:
HEAD https://rubygems.org/latest_specs.4.8.gz
302 Moved Temporarily
HEAD https://s3.amazonaws.com/production.s3.rubygems.org/latest_specs.4.8.gz
304 Not Modified
HEAD https://rubygems.org/specs.4.8.gz
302 Moved Temporarily
HEAD https://s3.amazonaws.com/production.s3.rubygems.org/specs.4.8.gz
304 Not Modified
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/.gemtest
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/BSDL
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/ChangeLog
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/Contributors.rdoc
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/History.rdoc
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/LICENSE
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/Manifest.txt
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/POSTGRES
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/README-OS_X.rdoc
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/README-Windows.rdoc
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/README.ja.rdoc
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/README.rdoc
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/Rakefile
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/Rakefile.cross
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/ext/errorcodes.def
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/ext/errorcodes.rb
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/ext/errorcodes.txt
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/ext/extconf.rb
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/ext/gvl_wrappers.c
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/ext/gvl_wrappers.h
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/ext/pg.c
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/ext/pg.h
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/ext/pg_connection.c
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/ext/pg_errors.c
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/ext/pg_result.c
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/ext/vc/pg.sln
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/ext/vc/pg_18/pg.vcproj
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/ext/vc/pg_19/pg_19.vcproj
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/lib/pg.rb
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/lib/pg/connection.rb
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/lib/pg/constants.rb
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/lib/pg/exceptions.rb
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/lib/pg/result.rb
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/sample/array_insert.rb
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/sample/async_api.rb
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/sample/async_copyto.rb
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/sample/async_mixed.rb
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/sample/check_conn.rb
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/sample/copyfrom.rb
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/sample/copyto.rb
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/sample/cursor.rb
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/sample/disk_usage_report.rb
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/sample/issue-119.rb
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/sample/losample.rb
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/sample/minimal-testcase.rb
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/sample/notify_wait.rb
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/sample/pg_statistics.rb
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/sample/replication_monitor.rb
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/sample/test_binary_values.rb
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/sample/wal_shipper.rb
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/sample/warehouse_partitions.rb
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/spec/data/expected_trace.out
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/spec/data/random_binary_data
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/spec/lib/helpers.rb
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/spec/pg/connection_spec.rb
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/spec/pg/result_spec.rb
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/pg-0.17.0/spec/pg_spec.rb
Building native extensions. This could take a while...
/usr/local/rvm/rubies/ruby-1.9.3-p392/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.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/rvm/rubies/ruby-1.9.3-p392/bin/ruby
--with-pg
--without-pg
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
/usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/mkmf.rb:461:in `try_link0'
from /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/mkmf.rb:476:in `try_link'
from extconf.rb:39:in `<main>'
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
Building has failed. See above output for more information on the failure.
Gem files will remain installed in /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/gems/1.9.1/gems/pg-0.17.0 for inspection.
Results logged to /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/gems/1.9.1/gems/pg-0.17.0/ext/gem_make.out
It's trying to build the gem pg, which has C or C++ code in it, and the compilation phase is not working. Under OS X, you must install XCode or get a compiler by other means, and the shell you're using to run bundle install must have the compiler in its path. I've compiled pg many times under OS X, though I have not upgraded to Mavericks.
If you have XCode installed, the above paragraph doesn't apply. You'll get additional information on what's going wrong if you try gem install pg. Try that and post the results.
The key is "You have to install development tools first." This is a strong hint that you don't have a proper compiler. This page says XCode must be v5.01 or later.
Thanks all for your help. The specific issue was resolved by me running the below command in terminal
brew install apple-gcc42
To clarify, I had the most recent XCode (with command line) and Mavericks, Ruby 1.9.3, Rails 3.2.12, and PG 9.3. I am unsure why that specific command worked when I already had the command line tools installed. The one change of the output of
gcc--version
was that --prefix=/Library/Developer/CommandLineTools/usr
changes to
--prefix=/Applications/Xcode.app/Contents/Developer/usr
Again, this change worked in practice, but I am not sure why this fixed things.
I've looked all the solutions in the internet for this, reinstalled everything and still nothing... When i do gem install pg i get:
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/Users/henriquedubugras/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb --with-pgsql->lib=/usr/local/Cellar/postgresql/9.2.1/lib --with-pg->config=/usr/local/Cellar/postgresql/9.2.1/bin/pg_config
Using config values from /usr/local/Cellar/postgresql/9.2.1/bin/pg_config
checking for libpq-fe.h... * 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.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/henriquedubugras/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
--with-pg
--without-pg
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
--with-pg-config
/Users/henriquedubugras/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:381:in try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/henriquedubugras/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:506:intry_cpp'
from /Users/henriquedubugras/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:970:in block in find_header'
from /Users/henriquedubugras/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:790:inblock in checking_for'
from /Users/henriquedubugras/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in block (2 levels) in postpone'
from /Users/henriquedubugras/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:inopen'
from /Users/henriquedubugras/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in block in postpone'
from /Users/henriquedubugras/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:inopen'
from /Users/henriquedubugras/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:280:in postpone'
from /Users/henriquedubugras/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:789:inchecking_for'
from /Users/henriquedubugras/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:969:in find_header'
from extconf.rb:41:in'
Gem files will remain installed in /Users/henriquedubugras/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/pg-0.14.1 for inspection.
Results logged to /Users/henriquedubugras/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/pg-0.14.1/ext/gem_make.out
I tried setting the pg_config path, my xcode is installed, my command line tools from xcode is installed, my ruby version is 1.9.3 installed by RVM.
My mac is OS X Mountain Lion
Thanks guys!
You're missing the Postgres client library header files (libpq-fe.h). In Debian the package is called libpq-dev. I don't know Mac packaging at all, but if there's no Mac respository building the PG client libs from source would work.
i would recommend installing rvm https://rvm.io/rvm/install
then run rvm requirements. this will install all required packages, you're probably missing "gcc49" after this install rails and yore good to install postgres. i would suggest postgresapp or postgresql.
I have been having a lot of troubles with Rails after upgrading to Mountain Lion.
Trying to trouble shoot these and searching for hours on the internet so far I have done the following to ensure my system has all the dependencies to run rails after the upgrade:
I updated my Homebrew installation
I updated my RVM installation
I installed the XCode command line tools
I installed GCC as mentioned
I upgraded my version of Ruby to
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]
My Rails version is verified as Rails 3.2.6
I also found out that Mountain Lion has some issues with Postgres so I saw this post and found out that I need to add this line to my Bash profile:
export PATH="/usr/local/bin:/usr/bin:$PATH"
Now I go to my Rails app that used to run fine on Snow Leopard before I upgraded, and when I run rails s at the command line I get the following error:
AM#~/Documents/RailsWS/app0815 >gem install pg
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/Users/AM/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... *** 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.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/AM/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
--with-pg
--without-pg
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
/Users/AM/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:368:in `try_do':
The complier failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/AM/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:452:in `try_cpp'
from /Users/AM/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:853:in `block in find_header'
from /Users/AM/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:693:in `block in checking_for'
from /Users/AM/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:280:in `block (2 levels) in postpone'
from /Users/AM/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/AM/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:280:in `block in postpone'
from /Users/AM/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/AM/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:276:in `postpone'
from /Users/AM/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:692:in `checking_for'
from /Users/AM/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:852:in `find_header'
from extconf.rb:41:in `<main>'
Gem files will remain installed in /Users/AM/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.14.1 for inspection.
Results logged to /Users/AM/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.14.1/ext/gem_make.out
When I go to the Rails app and try bundle install it fails at pg installation.
Download the postgresSQL installer from http://www.enterprisedb.com/products-services-training/pgdownload#osx
and then make your path look something like this:
PATH=$PATH:/Library/PostgreSQL/9.0/bin/ gem install pg
This would do!
Note: Please specify your postgreSQL installed version correctly in the path.
UPDATE(10/11/2015) (Taken from Heroku)
On OS X with Homebrew:
Install postgresql using:
brew install postgresql
Then install the gem using:
gem install pg -- --with-pg-config=/usr/local/bin/pg_config
On OS X with MacPorts:
gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
Hope this helps!
As banditKing says in his answer, need to tell the gem where to find the postgres binaries. You can use the binaries included with the excellent and easy postgres.app from Heroku ( http://postgresapp.com ) to install this gem instead of the EnterpriseDb version. The EnterpriseDB version is great, but an involved install for a dev machine.
Download Postgres.app on your system and add the internal bin directory to your path. I put it in /Applications/Postgres.app, so I used
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config
worked for me on 10.8.2, Ruby 1.9.3, pg-0.14.1, and the XCode CLI tools
Alternatively, use the Postgres app. IMO, it's the easiest and fastest way to get up and running with PostgreSQL and Rails on Mac.
For detailed instructions: http://blog.parsalabs.com/blog/2013/09/14/installing-postgresql-don-mac-os-x-and-using-it-as-your-rails-apps-database/
After installing Mavericks bundle update was throwing an error on the pg gem.
I use Brew to manage my packages and postgresql was already installed, but still I was getting the 'no pg_config' error.
The fix was to just brew uninstall postgresql, then brew install postgresql. After which I was immediately able to successfully run bundle update.