Topic: Gem update / install issue - ERROR: Failed to build gem native ext...

I noticed I didn't have sqlite3 installed so I did a sudo gem install sqlite3-ruby only to get the following error

Building native extensions.  This could take a while...
ERROR:  While executing gem ... (Gem::Installer::ExtensionBuildError)
    ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb update
creating Makefile


When I do a sudo gem update the gems that need updating (in my case RedCloth) will also give the same error.

Here is the full output when running sudo gem install sqlite3-ruby:

Building native extensions.  This could take a while...
ERROR:  Error installing sqlite3-ruby:
    ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb instal sqlite3-ruby
checking for fdatasync() in -lrt... no
checking for sqlite3.h... yes
checking for sqlite3_open() in -lsqlite3... no

make
make: *** No rule to make target `ruby.h', needed by `sqlite3_api_wrap.o'.  Stop.


Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4/ext/sqlite3_api/gem_make.out
Macintosh:~ Tate$ sudo gem install sqlite3-ruby
Building native extensions.  This could take a while...
ERROR:  Error installing sqlite3-ruby:
    ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb install sqlite3-ruby
checking for fdatasync() in -lrt... no
checking for sqlite3.h... yes
checking for sqlite3_open() in -lsqlite3... no

make
make: *** No rule to make target `ruby.h', needed by `sqlite3_api_wrap.o'.  Stop.


Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4/ext/sqlite3_api/gem_make.out


From all the google searches I've done, people have suggested that the ruby install is broken - I've seen a few solutions, but they were for Linux or Windows machines.

I'm on OSX 10.5 Leopard ~ does anyone have any clues? I have installed and updated gems before without this issue, most recently RedCloth (though I can't remember if that was pre or post Rails 2.1)

Last edited by riot (2008-09-04 23:16:19)

Re: Gem update / install issue - ERROR: Failed to build gem native ext...

Solved: my issue was an outdated version of Xcode (2.4 in my case). I just upgraded to 3.1 and that sorted out my problem.

If you're on Debian or another Linux flavor you may need to try sudo apt-get install ruby1.8-dev as the default ruby1.8 is missing a few important files.

Also, if you're on Windows and you get this error it may be that the particular gem you're having issues with has a Windows version and you will need to specify that.

Last edited by riot (2008-09-05 00:00:45)

Re: Gem update / install issue - ERROR: Failed to build gem native ext...

I am also on Leopard and am experiencing this issue. My XCode version is current.

What could be going on here?

Re: Gem update / install issue - ERROR: Failed to build gem native ext...

Hello, I try to install sqlite3-ruby but I have the same mistake that riot, but I use Kubuntu 8.1 and KDE 2.0 i install ruby1.8-dev but no works, someone can help my? thanks and Excuse my Englishman but I speak Spanish, gracias :-)

Re: Gem update / install issue - ERROR: Failed to build gem native ext...

Hey Solved problem I install libsqlite3-dev, gracias..
Salu2.-

Re: Gem update / install issue - ERROR: Failed to build gem native ext...

riot wrote:

Solved: my issue was an outdated version of Xcode (2.4 in my case). I just upgraded to 3.1 and that sorted out my problem.

If you're on Debian or another Linux flavor you may need to try sudo apt-get install ruby1.8-dev as the default ruby1.8 is missing a few important files.

Also, if you're on Windows and you get this error it may be that the particular gem you're having issues with has a Windows version and you will need to specify that.

Thanks!!!

Re: Gem update / install issue - ERROR: Failed to build gem native ext...

I was having the same issue as described here and the solution I found was a result of fixing several problems having to do with software versions.
My Sqlite3 binary was 3.6.4. The program 'gem' needs a version of 3.6.16+ in order to install Sqlite3-ruby properly. I used MacPorts to uninstall and reinstall Sqlite3, but it kept installing the same version. I tried downloading the Portfile and installing manually but to no avail. Finally, the solution was found when I updated MacPorts to the current version. Turns out I was using ~1.6 and current version is 1.9.2. After the upgrade I was able to do 'sudo port install sqlite3' and get the current version 3.7.7.1 which in turn let me use 'sudo gem install sqlite3'.
Phew!

Last edited by cwade (2011-07-05 22:41:59)

Re: Gem update / install issue - ERROR: Failed to build gem native ext...

I got the same problem on Amazon's EC2 basic Linux AMI. I needed to:
yum install make
(and nice to have:)
yum install gcc
These compilers are usually bundled with all standard Linux distributions, but not with Amazon EC2 basic AMIs. They are required for installing some Gems.

Worked for me

Re: Gem update / install issue - ERROR: Failed to build gem native ext...

VivisRock's wrote:

Hey Solved problem I install libsqlite3-dev, gracias..
Salu2.-

Gracias

Re: Gem update / install issue - ERROR: Failed to build gem native ext...

I had a similar error trying to build a Snorby install on top of a pretty standard factory SuSE 12.2 install I only had added Snort and a few lesser things to.  Nicely the suggestion about the Ruby dev library got it for me also, thanks!

With all the Ruby related items in their repositories It took a little looking with the Ruby dev search but sure enough I found that piece in the regular OpenSuSE repositories, clicked it and let the Software Manager install it for me.  When I went back to install RedCloth it was perfect.

Last edited by technicalfriend (2013-04-18 23:59:07)