mailcatcher: Failed to build gem native extension on Linux with no explanation

Hi There,

I’m using vagrant with Ubuntu 14.04 LTS (Trusty Tahr) and have installed sqlite3-dev. When I try to install mailcatcher, the installation fails and I don’t get a nice debug message telling me what went wrong. So I’m posting what happened here in hopes that someone will be able to help me out. Thanks!

Here’s what happened with the gem installer

vagrant@vvv:~$ sudo gem install mailcatcher
Building native extensions.  This could take a while...
ERROR:  Error installing mailcatcher:
        ERROR: Failed to build gem native extension.

        /usr/bin/ruby1.9.1 extconf.rb

Gem files will remain installed in /var/lib/gems/1.9.1/gems/eventmachine-1.0.3 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/eventmachine-1.0.3/ext/gem_make.out
vagrant@vvv:~$ cat /var/lib/gems/1.9.1/gems/eventmachine-1.0.3/ext/gem_make.out 
/usr/bin/ruby1.9.1 extconf.rb

Here’s what happened when I tried to install from source

vagrant@vvv:~/mailcatcher$ gem build mailcatcher.gemspec 
  Successfully built RubyGem
  Name: mailcatcher
  Version: 0.6.0
  File: mailcatcher-0.6.0.gem
vagrant@vvv:~/mailcatcher$ sudo gem install mailcatcher-0.6.0.gem 
Fetching: json-1.8.1.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing mailcatcher-0.6.0.gem:
        ERROR: Failed to build gem native extension.

        /usr/bin/ruby1.9.1 extconf.rb

Gem files will remain installed in /var/lib/gems/1.9.1/gems/json-1.8.1 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
vagrant@vvv:~/mailcatcher$ cat /var/lib/gems/1.9.1/gems/eventmachine-1.0.3/ext/gem_make.out 
/usr/bin/ruby1.9.1 extconf.rb

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 30

Most upvoted comments

I can confirm that installing sudo apt-get install ruby-dev libsqlite3-dev before sudo gem install mailcatcher worked fine.

You have gcc? Try ‘apt-get install build-essential’ before installing gem.

You have to install ruby-dev. It’s working with the 1.9 version of ruby.

This is what worked for me: `apt remove ruby

apt install software-properties-common

apt-add-repository ppa:brightbox/ruby-ng

apt update

apt install ruby2.3 ruby2.3-dev libsqlite3-dev

gem install mailcatcher`

I saw the error Failed to build gem native extension too on CentOS 7.3 and vagrant 1.8.7.

I resolved it after installing ruby-devel and gcc (yum -y install ruby-devel gcc)

sudo apt-get install ruby-dev is working for me too.

But now I have to update Ruby to Version >= 2.0

Fetching: mime-types-data-3.2016.0221.gem (100%)
ERROR:  Error installing mailcatcher:
    mime-types-data requires Ruby version >= 2.0.