I have just tried to recreate my local development environment for our Rails app, Supportress, and encountered an error installing a gem (mailcatcher) that depends on native extensions that need to be built:
Building native extensions. This could take a while...
ERROR: Error installing mailcatcher:
ERROR: Failed to build gem native extension.
current directory: /Users/petros/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/thin-1.5.1/ext/thin_parser
[...]
(__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
^
parser.rl:142:7: error: implicit declaration of function 'thin_http_parser_has_error' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
[...]
1 warning and 2 errors generated.
make: *** [parser.o] Error 1
make failed, exit code 2
This is the problematic part:
parser.rl:142:7: error: implicit declaration of function ‘thin_http_parser_has_error’ is invalid in C99 [-Werror,-Wimplicit-function-declaration]
This seems to be a problem with the latest version of Xcode tools. It has a version of Clang that throws an error on implicit functions used on the native extension code of various gems.
Following the suggested solution in the puma/puma repository for mail catcher or any other gem that needs building native extensions:
gem install mailcatcher -- --build-flags --with-cflags="-Wno-error=implicit-function-declaration"
Notice that I am not using bundler in this instance as mailcatcher needs to be installed separately, not as part of your Gemfile.
You can apply this to any of your gems that have the same problem.
Here’s what I am doing
At Amignosis, I pour my heart and skill into crafting slowly brewed software, one thoughtful line at a time. I am craftsman in a world of complexity and low-quality solutions. I am a shoemaker. I take the time to create simple, timeless software built to last. Check what I am doing now and talk to me.
Leave a Reply