Category Archives: Ruby on Rails

Bundler Failing to Build Native Extensions

It was apparent that my 2011 MacBook Air needed a rebuild when it would sit, sometimes up to three minutes after coming back from sleep, screen lock, or restart, loading the login screen. I have worked at three different places of employment with this laptop, each place requiring a number of different processes and applications running on the machine in order for me to work effectively. It had finally become out of control and enough was enough. I wiped the machine and performed a fresh install of Mavericks.

Everything was going very smoothly until it came to install my gems for the current Rails project I am working on. Every single time I would try to bundle install gems, I would get the same error, for different gems. The one erring out below happens to be the do_postgres gem, but the error was always the same:

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for main() in -lpq... yes
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for postgres.h... yes
checking for mb/pg_wchar.h... no
*** 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
--with-pgsql-server-dir
--without-pgsql-server-dir
--with-pgsql-server-include
--without-pgsql-server-include=${pgsql-server-dir}/include
--with-pgsql-server-lib
--without-pgsql-server-lib=${pgsql-server-dir}/
--with-pgsql-client-dir
--without-pgsql-client-dir
--with-pgsql-client-include
--without-pgsql-client-include=${pgsql-client-dir}/include
--with-pgsql-client-lib
--without-pgsql-client-lib=${pgsql-client-dir}/
--with-pqlib
--without-pqlib
Could not find PostgreSQL build environment (libraries & headers): Makefile not created

extconf failed, exit code 1

I must have Googled a hundred sites. Most answers I found suggested to install the Xcode command line tools. I did that. And did it again. And probably again, just because I’m a little insane like that. Other people suggested that it was a Postgres issue and simply uninstall Postgres, reinstall and observe the magic. There was no magic for me. Nothing.

Frustrated, I typed gem install do_postgres from the command line, not using bundler. It worked! But why? Finally my awesome husband and I sat down to figure this out.

We found an issue similar to mine here and TimMoore stated “I’d bet that the problem is that Bundler itself is installed as gem under the system Ruby, rather than the one in ~/.rubies.” Bingo.

I use rbenv to manage my Ruby versions. It seemed for some reason bundler was using the system Ruby rather than what was specified by rbenv. I wish I could go back in time to verify this, but odds are, for some reason, I installed bundler before I installed rbenv. I don’t know why I would have done that, and I honestly do not remember. We updated the /usr/bin/bundler to look in /Users/jpayne/.rbenv/shims/ruby rather than /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby and that worked.

I, of course, was not going to accept that updating that file was the solution, so I uninstalled bundler, went back into my project directory (with my rbenv gemset in place) and reinstalled bundler. I then did a bundle install to try it out and was extremely pleased to discover that building the native dependencies for all gems had been successful.

My laptop is now a bit speedier because of the rebuild, and I have my project up and running again.

erubycon 2009

Yep. I’ll be there! Loved it last year and looking forward to it this year as well. Hosted by EdgeCase, it’s a conference that presents Ruby and Ruby on Rails as a solution for the enterprise. Held in Columbus, OH, it’s relatively close to home for me, which makes it convenient, and the lineup of speakers is great. See the erubycon site for more information, and better yet, register while you’re there. Early registration ends Monday and is $250, but even at the full price of $299 it’s still well worth attending.

Background Processing with Nanite

Below is a short presentation I gave to my team about Nanite and the benefits of using it for background processing. Unfortunately the slide show notes are not available but at least you can get an idea of what I talked about and where I got my information.

The application that I work on, written in Ruby on Rails, was previously using BackgrounDRb for its background processing but we have decided to give Nanite a try because of its flexibility and scalability. I’ve been very pleased so far with the choice.