jyli7
jyli7

Reputation: 2759

Error while installing cucumber (involving gherkin)

I'm trying to set up cucumber for rails. I included this in my Gemfile and ran bundle install.

  gem 'cucumber-rails'
  gem 'database_cleaner'

I got this error. What should I do?

ERROR:  Error installing gherkin:
    ERROR: Failed to build gem native extension.

        /Users/[my_user_name]/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
checking for main() in -lc... *** 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.

Upvotes: 0

Views: 1034

Answers (1)

jayeff
jayeff

Reputation: 1787

This question is a bit old, but as I just had a similar problem on my machine I will document my solution here.

The problem seems to be related to OS X Lion, GCC, clang etc. (see https://github.com/carlhuda/bundler/issues/1590 and https://github.com/carlhuda/bundler/issues/1600). As how ruby was compiled seems to be the problem I decided to re-install (and also upgrade) ruby.

Here is what solved this issue for me:

  • I use the Command Line Tools for Xcode package.
  • Furthermore the current version of rbenv and ruby-build (both installed via homebrew)
  • rbenv install 1.9.3-p125 failed (see https://github.com/sstephenson/ruby-build/issues/129 and https://github.com/sstephenson/ruby-build/issues/130)
  • remove the require_gcc line for 1.9.3-p125 (if installed with homebrew you find the file under /usr/local/Cellar/ruby-build/20120216/share/ruby-build/1.9.3-p125)
  • finally successfully install 1.9.3-p125 with env CC=/usr/bin/gcc rbenv install 1.9.3-p125

Complicated but I can now install gems with natiive extensions.

Hope this helps.

Update: btw. It is possible to keep using ruby-1.9.2-p290, all you have to do is re-install it.

  • First "uninstall" the old ruby-1.9.2-p290: rm -rf .rbenv/versions/1.9.2-p290
  • Next remove the require_gcc line for 1.9.2-p290
  • Finally install with env CC=/usr/bin/gcc rbenv install 1.9.2-p290

Upvotes: 3

Related Questions