I’m try to install the SQLite gem on a Fedora 9 Linux box with Ruby 1.8.6, Rails 2.2.2, gem 1.3, and sqlite-3.5.9. Here’s the command I’m running and its results:
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/bin/ruby extconf.rb install sqlite3-ruby can't find header files for ruby. Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4 for inspection. Results logged to /usr/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4/ext/sqlite3_api/gem_make.out
gem_make.out just repeats what was already sent to the console. How can I install this gem?
The SQLite RubyGem isn’t actually a RubyGem, it’s a “CGem”, IOW it’s written in C. This means it has to be compiled and linked to the Ruby interpreter when you install it and in order to do that it needs the C header files for the Ruby interpreter.
If you compile Ruby yourself, those header files will be installed automatically, however, in RedHat-ish systems, such header files are usually packaged in a seperate package, called
<whatever>-dev. So, in this case you will need to install the
ruby-dev package and possibly the
libsqlite3-dev (Ubuntu) or
sqlite-devel (Fedora) package as well.
However, you might be better off just installing your Operating System’s pre-packaged
libsqlite3-ruby package, that way all the dependencies are automatically satisfied.
(Note: all package names pulled out of thin air, might be different on your system.)
You probably need the ruby dev package. For Ubuntu you have to install ruby1.8-dev which includes the ruby header files. A quick google says that the yum package is ruby-devel. so run this:
sudo yum install ruby-devel
I faced problem installing sqlite3-ruby gem on my fedora 13 box.
It was fixed after sudo yum install sqlite-devel
sudo apt-get install ruby-dev
fixed it for me.
When I had that problem:
gem install sqlite3 -v '1.3.9' Building native extensions. This could take a while... ERROR: Error installing sqlite3: ERROR: Failed to build gem native extension.
For me worked, installing the “libsqlite3-dev” with:
apt-get install libsqlite3-dev
On Ubuntu 9 and 10 try:
sudo apt-get install ruby-dev sudo apt-get install sqlite3-dev
gem install sqlite3
Run the following for Fedora OS:
yum install rubygem-sqlite3
Do you have all the source code required to build sqlite3-ruby? Gem is trying to compile some C code and cannot find the headers. You can probably use a fedora rpm for sqlite3-ruby (I don’t use fedora, but I’m sure one exists) if you prefer to forgo compiling. Personally for ruby stuff, I prefer to use gem rather than a distro’s packaging system.
I’m not really familiar with Fedora, but in Ubuntu when you are installing packages you have apt-get, and you have to install the build-essentials which includes gcc and other compilation tools for C. I would say that could be your issue, and you make look into how that can be install either using RPM or apt-get on Fedora.
I fixed the problem on my OLPC (Fedora 9) by installing ‘gcc’ oddly enough. It seems like it should have been one of those dev packages, but no.
Also, regarding the other packages, the suffix is “-devel”, not “-dev”, so make sure you get those ending right: “ruby-devel”, “sqlite-devel”…
Once you get that installed, if you get errors about your gems being too old “< 1.3.1” when you try to run various rails scripts, eg: script/server or script/console, google “upgrade_rubygems” to fix that problem…
Run “sudo yum install sqlite-devel” and then “gem install sqlite3”. Had the same problem on my Fedora 15.
I had this same exact issue…instead of gem’ing the missing pieces I used synaptic on unbuntu.
The key package for me was libsqlite-ruby1.9.1 … I documented my experience (for reference) with this error at :