3

I had to reinstall a Rails app onto a fresh OSX Snow Leopard installation.

I had a hair pulling session just trying to get the pg gem to install properly with Rails. First I installed PgSql 9 through this link. However, I started getting errors when trying to run bundle install:

Installing pg (0.10.0) with native extensions /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:529:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

        /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/bin/ruby extconf.rb 
checking for pg_config... yes
Ruby cflags: " -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long  -fno-common -pipe"
MacOS X build: fixing architecture flags:
  finding flags common to both Ruby and PostgreSQL...

*** Your PostgreSQL installation doesn't seem to have an architecture in common with the running ruby interpreter (["ppc", "i386", "x86_64"] vs. [])
I'll continue anyway, but if it fails, try setting ARCHFLAGS.
  testing for architecture: "ppc"
  testing for architecture: "i386"
  testing for architecture: "x86_64"
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
    --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=/Users/Chris/.rvm/rubies/ruby-1.9.2-p136/bin/ruby
    --with-pg
    --without-pg
    --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
/Users/Chris/.rvm/rubies/ruby-1.9.2-p136/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/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/mkmf.rb:452:in `try_cpp'
    from /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/mkmf.rb:853:in `block in find_header'
    from /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/mkmf.rb:693:in `block in checking_for'
    from /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/mkmf.rb:280:in `block (2 levels) in postpone'
    from /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/mkmf.rb:280:in `block in postpone'
    from /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/mkmf.rb:276:in `postpone'
    from /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/mkmf.rb:692:in `checking_for'
    from /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/mkmf.rb:852:in `find_header'
    from extconf.rb:123:in `<main>'


Gem files will remain installed in /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/pg-0.10.0 for inspection.
Results logged to /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/pg-0.10.0/ext/gem_make.out
    from /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:507:in `block in build_extensions'
    from /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:482:in `each'
    from /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:482:in `build_extensions'
    from /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:156:in `install'
    from /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/bundler-1.0.10/lib/bundler/source.rb:96:in `install'
    from /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/bundler-1.0.10/lib/bundler/installer.rb:55:in `block in run'
    from /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/bundler-1.0.10/lib/bundler/spec_set.rb:12:in `block in each'
    from /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/bundler-1.0.10/lib/bundler/spec_set.rb:12:in `each'
    from /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/bundler-1.0.10/lib/bundler/spec_set.rb:12:in `each'
    from /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/bundler-1.0.10/lib/bundler/installer.rb:44:in `run'
    from /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/bundler-1.0.10/lib/bundler/installer.rb:8:in `install'
    from /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/bundler-1.0.10/lib/bundler/cli.rb:226:in `install'
    from /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/bundler-1.0.10/lib/bundler/vendor/thor/task.rb:22:in `run'
    from /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/bundler-1.0.10/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
    from /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/bundler-1.0.10/lib/bundler/vendor/thor.rb:246:in `dispatch'
    from /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/bundler-1.0.10/lib/bundler/vendor/thor/base.rb:389:in `start'
    from /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/bundler-1.0.10/bin/bundle:13:in `<top (required)>'
    from /Users/Chris/.rvm/gems/ruby-1.9.2-p136/bin/bundle:19:in `load'
    from /Users/Chris/.rvm/gems/ruby-1.9.2-p136/bin/bundle:19:in `<main>'

I came across this article, which suggests I install PgSql 8.3 via Mac Ports. So I did that, and followed the rest of the instructions in the article. I managed to bundle install and start the rails server via rails s without any problems.

My main concern, is that I believe I have 2 installations of PgSql. One is version 9 and the other version 8.3. Should I uninstall version 9 for whatever reason? Or does the latest installation override?

Or should I not worry about this? Second, I've searched everywhere for proper documentation on how to uninstall version 9 on a Mac OSX, to no avail.

  • Haven't tried it on a Mac, but if you go into psql can you get the version and see which one is running? If you reboot do you get an error cuz one started and the 2nd was trying to listen on the same port or anything like that? –  Feb 05 '11 at 02:26
  • On a Mac, I don't notice any errors anywhere when I reboot. Should I check some kind of log file for this? Running psql, I see: Welcome to psql 8.3.13 (server 9.0.3), the PostgreSQL interactive terminal. WARNING: You are connected to a server with major version 9.0, but your psql client is major version 8.3. Some backslash commands,such as \d, might not work properly. –  Feb 05 '11 at 09:44

1 Answers1

1

I don't know how it works on Mac, but on Linux the EnterpriseDB installer leaves an uninstall script, possibly linked to some menu entry. You should look for that.

The two installations should be able to coexist peacefully. But if you don't need the installation, you should consider removing it, as a matter of course.

In general, I do recommend using Macports for PostgreSQL and other software.

Peter Eisentraut
  • 3,575
  • 1
  • 23
  • 21