views:

7258

answers:

6

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?

+1  A: 

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.

barneytron
The fedora rpm for the mysql headers is something like 'mysql-dev', so the correct sqlite rpm is likely to be 'sqlite3-dev'
erik
I'm using FreeBSD 7.1 right now, and I have the sqlite3-3.6.4 port installed, which provided everything that gem needed if I remember right. I'm trying to check out Rails 2.2.2 myself. Good luck Erik!
barneytron
A: 

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.

Tim K.
It's yum on Fedora, but this is NOT the issue. It's the libsqlite3-ruby issue.
Yar
+23  A: 

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

Jörg W Mittag
Damn SO is cool, this is actually the right answer... I was lost trying to install the SqlLite and the problem was producing new error messages every minute. Now if the questioner would just mark this as the right answer, we'd be in business.
Yar
On Ubuntu I did apt-get install libsqlite3-ruby and it worked perfectly. As root, of course...
Yar
Or if you wanted to install the gem, you would need to apt-get install ruby-dev, just as Jorg says.
Shadowfirebird
Once again Jorg, your info has come in handy to ease my learning. Thanks again.
Mark Essel
+5  A: 

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

hacintosh
A: 

The comments above made a lot of sense, but none solved the problem. I have the developer packages for everything involved. There seems to be something going on between Fedora's package manager (yum) and gem. I used yum to uninstall and then reinstall ruby and gem. Now, any gem command gives me this:

/usr/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:92:in `load_specification': private method `specification_version=' called for #<Gem::Specification:0xb7e23ef4> (NoMethodError)
    from /usr/lib/ruby/site_ruby/1.8/rubygems/specification.rb:421:in `initialize'
    from (eval):1:in `new'
    from (eval):1:in `load_specification'
    from /usr/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:128:in `eval'
    from /usr/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:92:in `load_specification'
    from /usr/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:128:in `load_gems_in'
    from /usr/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:127:in `each'
    from /usr/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:127:in `load_gems_in'
     ... 14 levels...
    from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
    from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
    from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:111:in `manage_gems'
    from /usr/bin/gem:10

...and yum also throws this every 5 minutes:

Error Type: &lt;class &apos;yum.Errors.PackageSackError&apos;&gt;

The Fedora install isn't even that old. I'm not sure what else to do at this point, short of using a different distro or OS X.

Eric Noob
Your Yum errors are not caused by your Ruby errors. You'll need to get them fixed before trying to get Ruby working.
Josh Kelley
A: 

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

HTH...