What to do if the gherkin gem does not compile

On my GNU/Linux box, the gherkin gem doesn’t want to compile – and it is a dependency of cucumber, so that’s pretty annoying.

The errors returned when trying to build it are:

matteo@orchid:~$ gem install gherkin
Building native extensions.  This could take a while...
ERROR:  Error installing gherkin:
ERROR: Failed to build gem native extension.

/home/matteo/.rvm/rubies/ruby-head/bin/ruby extconf.rb
checking for main() in -lc... yes
creating Makefile

make
compiling gherkin_lexer_ar.c
cc1: warnings being treated as errors
/Users/ahellesoy/scm/gherkin/tasks/../ragel/i18n/ar.c.rl: In function ‘unindent’:
/Users/ahellesoy/scm/gherkin/tasks/../ragel/i18n/ar.c.rl:252:3: error: ISO C90 forbids mixed declarations and code
/Users/ahellesoy/scm/gherkin/tasks/../ragel/i18n/ar.c.rl: In function ‘store_multiline_kw_con’:
/Users/ahellesoy/scm/gherkin/tasks/../ragel/i18n/ar.c.rl:285:3: error: ISO C90 forbids mixed declarations and code
/Users/ahellesoy/scm/gherkin/tasks/../ragel/i18n/ar.c.rl: In function ‘store_pystring_content’:
/Users/ahellesoy/scm/gherkin/tasks/../ragel/i18n/ar.c.rl:322:3: error: ISO C90 forbids mixed declarations and code
/Users/ahellesoy/scm/gherkin/tasks/../ragel/i18n/ar.c.rl: In function ‘CLexer_init’:
/Users/ahellesoy/scm/gherkin/tasks/../ragel/i18n/ar.c.rl:364:3: error: ISO C90 forbids mixed declarations and code
/Users/ahellesoy/scm/gherkin/tasks/../ragel/i18n/ar.c.rl: In function ‘CLexer_scan’:
/Users/ahellesoy/scm/gherkin/tasks/../ragel/i18n/ar.c.rl:378:3: error: ISO C90 forbids mixed declarations and code
/Users/ahellesoy/scm/gherkin/tasks/../ragel/i18n/ar.c.rl:381:3: error: ISO C90 forbids mixed declarations and code
/Users/ahellesoy/scm/gherkin/tasks/../ragel/i18n/ar.c.rl:180:5: error: ISO C90 forbids mixed declarations and code
/Users/ahellesoy/scm/gherkin/tasks/../ragel/i18n/ar.c.rl:230:9: error: ISO C90 forbids mixed declarations and code
/Users/ahellesoy/scm/gherkin/tasks/../ragel/i18n/ar.c.rl:230:9: error: ISO C90 forbids mixed declarations and code
make: *** [gherkin_lexer_ar.o] Errore 1

Fortunately, the error is pretty self-explanatory. You can have it install by just doing:

gem install gherkin -- --with-cflags="-std=c99"

That will fix it. Cheers,
Matteo

Advertisements

3 Responses to What to do if the gherkin gem does not compile

  1. You saved me a LOT of time with your suggestion. Thanks a bunch!

  2. Jay says:

    Nope. Same problem occurs. Not sure why, as my error message was exactly the same as yours.

    • tchernobog says:

      Theoretically, the gem was updated some time ago to solve this issue, so this workaround should not be necessary. Could you however be so kind to put your error message in a pastebin, and post here the link? I’ll have a look.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: