small medium large xlarge

19 Apr 2010, 04:33
Steve Nicholson (8 posts)

I’ve played with Rails 1 a little in the past and have decided to try to work on learning Rails 3 so I got the beta of the new book. I’m running Snow Leopard and am having trouble getting up and running. I ran all the commands at the bottom of page 23, but when I try to run the code at the top of page 24 in irb, I get “no such file to load” errors on both @require@ lines.

Here’s a Terminal transcript showing what is installed:

$ sudo gem install sqlite3-ruby
Building native extensions.  This could take a while...
Successfully installed sqlite3-ruby-1.2.5
1 gem installed
$ ruby --version
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin9]
$ rails --version
Rails 2.3.5
$ irb --version
irb 0.9.5(05/04/13)
$ sqlite3 --version
$ rake --version
rake, version 0.8.7
$ gem --version

and here’s the irb transcript:

irb(main):001:0> require 'rubygems'
LoadError: no such file to load -- rubygems
	from (irb):1:in `require'
	from (irb):1
irb(main):002:0> require 'sqlite3'
LoadError: no such file to load -- sqlite3
	from (irb):2:in `require'
	from (irb):2

I’m not really sure where to go from here. If someone can land a hand, I’d appreciate it.

19 Apr 2010, 15:23
Sam Ruby (634 posts)

Theory: you have two versions of ruby installed (this is normal), but only one copy of gems installed (also OK). The problem may be that you have your path set up so that the version of ruby that is being picked up is not the one associated with rubygems.

$ /usr/bin/ruby -v
ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]
$ which gem
$ which ruby
$ echo $PATH

Note that the directoriess for @gem@ and @ruby@ match, and that directory is in my PATH before @/usr/bin/@. My PATH is set in @.bash_login@.

19 Apr 2010, 19:53
Steve Nicholson (8 posts)

Thanks, Sam. Your theory was correct. Ruby was in /opt/local/bin and gem was in /usr/bin. I installed gem into /opt/local/bin. Then I had 32-bit vs 64-bit problems. @sudo gem install sqlite3-ruby@ gave the results

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

/opt/local/bin/ruby extconf.rb
checking for fdatasync() in -lrt... no
checking for sqlite3.h... yes
checking for sqlite3_open() in -lsqlite3... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
Gem files will remain installed in /opt/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.5 for inspection.
Results logged to /opt/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.5/ext/sqlite3_api/gem_make.out

This is the relevant section from mkmf.log

"/usr/bin/gcc-4.0 -o conftest -I. -I/opt/local/lib/ruby/1.8/i686-darwin9 -I. -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE  -I/opt/local/include -O2  -fno-common -pipe -fno-common   conftest.c  -L. -L/opt/local/lib -L. -L/opt/local/lib     -lruby-static -lsqlite3  -lpthread -ldl -lobjc  "
ld: warning: in /opt/local/lib/libsqlite3.dylib, file was built for unsupported file format which is not the architecture being linked (i386)

And indeed @file /opt/local/bin/ruby@ says “Mach-O executable 386” and @file /opt/local/lib/libsqlite3.0.dylib@ told me libsqlite3 was x86_64 (I don’t have the exact output).

So I did @sudo port upgrade –force sqlite3 +universal@ and got sqlite3 and all its dependencies to build x86_64/i386 universal libraries.

The code at the top of page 24 now works fine. It tells me I have sqlite3

I think that should settle things. I don’t suppose there’s any compelling reason to compile Ruby 1.8.7 in 64-bit is there?

04 May 2010, 23:05
Manuel E Vidaurre Arenas (8 posts)

You should try to use rvm it is a very nice tool to handle different Ruby Versions and Named Gem Sets. Check

12 May 2010, 03:01
Marc Beaudry (3 posts)


I seem to have a related problem. The link/association to sqlite3 is incorrect and causing errors such as:

“NameError: uninitialized constant SQLite3::Driver::Native::Driver::API”

When I try something like this:

$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'sqlite3'
=> true
irb(main):003:0> tempname = "test.sqlite#{3+rand}"
=> "test.sqlite3.38642802278689"
irb(main):004:0> db =
NameError: uninitialized constant SQLite3::Driver::Native::Driver::API
	from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.5/lib/sqlite3/driver/native/driver.rb:76:in `open'
	from /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.5/lib/sqlite3/database.rb:76:in `initialize'
	from (irb):4:in `new'
	from (irb):4

Here is the info on my machine:

  • Running on Mac OS X Leopard
  • Multiple versions of ruby, rails, sqlite3, … on my Mac (I would like to clean that up as I don’t believe I need the older stuff. But maybe I need it for other people’s rails apps? Any link you can send me on how to cleanup old rails, ruby, irb, gem and sqlite3 versions I would appreciate).

When I run

for $cmd in ruby irb rails rake gem sqlite3; do which $cmd; done

I get:

$ for cmd in ruby irb rails rake gem sqlite3; do which $cmd; done
  • If I look at the versions, I get:
$ ruby --version
ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-darwin9.6.0]
$ irb --version
irb 0.9.5(05/04/13)
$ rails --version
Rails 3.0.0.beta3
$ rake --version
rake, version 0.8.7
$ gem --version
$ sqlite3 --version

I believe this is ok and I followed the AWDwR4 instructions in section 1.2.

So, what should I do next. I tried “sudo gem install sqlite3-ruby”, “sudo gem install libsqlite3-ruby1.8” and “sudo ln -s /Developer/SDKs/MacOSX10.6.sdk/usr/lib/libsqlite3.0.dylib /usr/local/lib/libsqlite3.dylib” without any luck.

Your help would be appreciated.

Thanks so much!


12 May 2010, 03:48
Sam Ruby (634 posts)

Marc: you say “Leopard” and then later say “MacOSX10.6”.

A google search for the symptom you have leads to the same post that is mentioned in this reply.

Can you try upgrading to xcode 3.2.2?

12 May 2010, 11:22
Marc Beaudry (3 posts)

Hi Sam! :o)

Yes, sorry “Snow Leopard” – big difference.

I had found many links regarding the issue but none had worked. I did not fall on the link you provided above.

I did upgrade my version of XCode from 3.1.2 to 3.2.2 but no luck.

I will retry from scratch with instructions from Hivelogic. If you or someone else believes I should try something else, let me know. I will begin my rebuilding later today.

Thanks! :o)

17 May 2010, 21:46
Marc Beaudry (3 posts)

Just an update.

As indicated, I followed the Hivelogic instructions (no issues here) and then worked on getting the latest SQLite3 version running, which ended up being a challenge; I had so many versions of SQLite3 on my machine (many other programs use it) plus the startup process was invoking an executable in some obscure folder that it took a while for me (yes, emphasis on “for me” here) to get the latest executable to be the one to run by default.

All is now running fine.


26 May 2010, 16:37
Misha Rabinovich (1 post)

I had 2 taf2-curb installs misha@mishanotebook-2 ~/Projects/project1 $ sudo gem uninstall taf2-curb

Select gem to uninstall: 1. taf2-curb- 2. taf2-curb- 3. All versions

I uninstalled them both and did:

sudo env ARCHFLAGS=”-arch x86_64” gem install taf2-curb

then reinstalled sqlite3

sudo env ARCHFLAGS=”-arch x86_64” gem install sqlite3-ruby

And everything is happy. Thanks anyway. Misha

20 May 2011, 03:01
Anthony Prestia (2 posts)

I’m having similar trouble and thought I would add to this thread rather than start my own.

Whenever I try to run @rake@ I get a number of errors that end with rake @aborted!@ and @stack level too deep@. I think this is because rake is installed in the wrong directory.

For some reason (even after multiple installs) I can’t get rake in the proper directory. Any ideas? Here are the relevant file locations:

$ which ruby gem irb rake
21 May 2011, 00:58
Anthony Prestia (2 posts)

Solved my own problem. All I had to do was delete rake-0.8.7.gemspec and everything worked fine. In the event that anyone else has this problem, here is what I did:

sudo rm ~/.rvm/gems/ruby-1.9.2-p180@global/specifications/rake-0.8.7.gemspec
21 May 2011, 10:30
renne wilam (3 posts)

It is such a relief when you get immediate answers for your problems and it must be great to understand what went wrong when trying to get started with Snow Leopard!! I’ve heard so much about it and have been planning to try it out for some and now that I’ve read about it here, am planning to test it out one of these days as well!! It was really an interesting read and it is through such post that our interest to know about something new is also aroused!!

You must be logged in to comment