Search code examples
rubyhomebrewrbenvboxen

rbenv and gems that require C extensions


So I'm trying to install the audite gem, but having issues with rbenv:

$ bundle install
Fetching gem metadata from https://rubygems.org/...
Installing audite (0.3.0)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /opt/boxen/rbenv/versions/1.9.3-p448/bin/ruby extconf.rb
checking for mpg123.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=/opt/boxen/rbenv/versions/1.9.3-p448/bin/ruby
please install mpg123 headers


Gem files will remain installed in /opt/boxen/rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/audite-0.3.0     for inspection.
Results logged to /opt/boxen/rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/audite-0.3.0/ext/mpg123/gem_make.    out

An error occurred while installing audite (0.3.0), and Bundler cannot continue.
Make sure that `gem install audite -v '0.3.0'` succeeds before bundling.

I know that these gems require c extensions, and I have them installed with homebrew. And if I go into the cellar for homebrew I can see the file it's looking for (mpg123.h)

/opt/boxen/homebrew/Cellar/mpg123/1.15.4/include/mpg123.h

So, is there a way to add this into the rbenv environment without just sim-linking or copying it directly into /opt/boxen/rbenv/versions/1.9.3-p448/


Solution

  • So in the end one of the following things fixed it for me, I'm not sure which because I'd rebuild and changed my machine few times since I had this issue:

    • Switched to Ruby 2.0.0
    • Upgraded to Mavericks (which does change some stuff with xcode stuff I believe)
    • Updated my Boxen/Brew to latest version