Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I install the SQLite gem?

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?

like image 247
Eric Noob Avatar asked Jan 07 '09 17:01

Eric Noob


People also ask

How do you install gem?

To install a gem, use gem install [gem] . Browsing installed gems is done with gem list . For more information about the gem command, see below or head to RubyGems' docs. There are other sources of libraries though.

What is gem native extension?

“Native extensions” are the glue that connects a Ruby gem with some other non-Ruby software component or library present on your machine.

Where are gems installed rails?

When you use the --user-install option, RubyGems will install the gems to a directory inside your home directory, something like ~/. gem/ruby/1.9. 1 . The commands provided by the gems you installed will end up in ~/.

What does gem install rails do?

Installing Gems The install command downloads and installs the gem and any necessary dependencies then builds documentation for the installed gems. Here the drip command depends upon the rbtree gem which has an extension.


2 Answers

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.)

like image 53
Jörg W Mittag Avatar answered Sep 23 '22 19:09

Jörg W Mittag


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

like image 38
hacintosh Avatar answered Sep 21 '22 19:09

hacintosh