Problem on page 133 of Simply Rails 2

Hey guys not sure whats going on here.


[root@jayvm shovell]# ruby script/console
Loading development environment (Rails 2.3.5)
>> s = Story.new
MissingSourceFile: no such file to load -- sqlite3
	from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
	from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
	from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
	from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in `new_constants_in'
	from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
	from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/kernel/requires.rb:7:in `require_library_or_gem'
	from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings'
	from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/kernel/requires.rb:5:in `require_library_or_gem'
	from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/sqlite3_adapter.rb:10:in `sqlite3_connection'
	from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in `send'
	from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in `new_connection'
	from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:245:in `checkout_new_connection'
	from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:188:in `checkout'
	from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in `loop'
	from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in `checkout'
	from /usr/lib/ruby/1.8/monitor.rb:238:in `synchronize'
	from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:183:in `checkout'
	from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:98:in `connection'
	from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:326:in `retrieve_connection'
	from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_specification.rb:123:in `retrieve_connection'
	from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_specification.rb:115:in `connection'
	from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:1271:in `columns'
	from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:3014:in `attributes_from_column_definition_without_lock'
	from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/locking/optimistic.rb:55:in `attributes_from_column_definition'
	from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:2434:in `initialize'
	from (irb):1:in `new'
	from (irb):1>> 

however db:migrate works fine:


[root@jayvm shovell]# rake db:migrate
(in /var/www/jaymerritt.com/shovell)
[root@jayvm shovell]# 

also


[root@jayvm shovell]# gem list

*** LOCAL GEMS ***

actionmailer (2.3.5)
actionpack (2.3.5)
activerecord (2.3.5)
activeresource (2.3.5)
activesupport (2.3.5)
fastthread (1.0.7)
mysql (2.8.1)
passenger (2.2.11)
rack (1.1.0, 1.0.1)
rails (2.3.5)
rake (0.8.7)
sqlite3-ruby (1.2.5)
[root@jayvm shovell]# 

i can’t figure out what could be wrong.

will you show me the config/database.yml file?

Hello!
Thank you for your response.


[root@jayvm config]# cat database.yml
# SQLite version 3.x
#   gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
  adapter: sqlite3
  database: db/development.sqlite3
  pool: 5
  timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: sqlite3
  database: db/test.sqlite3
  pool: 5
  timeout: 5000

production:
  adapter: sqlite3
  database: db/production.sqlite3
  pool: 5
  timeout: 5000
[root@jayvm config]

Your db file looks fine.

Try this.

Go to config/environment.rb, unless you have already altered this file there should be commented out line that reads:

config.gem “sqlite3-ruby”, :lib => “sqlite3”

uncomment this line by deleting the # and save the file. Go back to your terminal/command prompt (make sure you are in the root directory of your app) and use:

rake gems:install

After that has executed try running the console.

Here’s what happened.


[root@jayvm shovell]# ruby script/console
Loading development environment (Rails 2.3.5)
/usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprecated and will be removed on or after August 2010.  Use #requirement
Missing these required gems:
  sqlite3-ruby  

You're running:
  ruby 1.8.5 at /usr/bin/ruby
  rubygems 1.3.6 at /root/.gem/ruby/1.8, /usr/lib/ruby/gems/1.8

Run `rake gems:install` to install the missing gems.
[root@jayvm shovell]# rake gems:install
(in /var/www/jaymerritt.com/shovell)
[root@jayvm shovell]# ruby script/console
Loading development environment (Rails 2.3.5)
/usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprecated and will be removed on or after August 2010.  Use #requirement
Missing these required gems:
  sqlite3-ruby  

You're running:
  ruby 1.8.5 at /usr/bin/ruby
  rubygems 1.3.6 at /root/.gem/ruby/1.8, /usr/lib/ruby/gems/1.8

Run `rake gems:install` to install the missing gems.
[root@jayvm shovell]# 

wait i am having conflicting paths i think.

yeah i want to be running off the enterprise installation.


[root@jayvm shovell]# locate gem_dependency.rb
/home/rubygems-1.3.1/test/test_gem_dependency.rb
/home/rubygems-1.3.5/test/test_gem_dependency.rb
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb
/root/Temp/Sources/ruby-enterprise-1.8.7-2010.01/rubygems/test/test_gem_dependency.rb
/usr/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/rails/gem_dependency.rb
/usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb
/usr/lib/ruby/gems/1.8/gems/rubygems-update-1.3.5/test/test_gem_dependency.rb
/usr/lib/ruby/gems/1.8/gems/rubygems-update-1.3.6/test/test_gem_dependency.rb
[root@jayvm shovell]# 

ugh

How do I tell ruby which gems to be using?

Looks like you have both Rails 2.3.3 and 2.3.5, but it also looks like the enterprise edition is the one you are using since it is v2.3.5. To create an app using a specific rails version you use

rails 2.3.x app

In this case it maybe easier to freeze the version of rails you are using

rake rails:freeze:gems

This saves the version of rails your app is using to vendors/plugins directory and your app is then locked into that version. If later you want to upgrade use

rake rails:unfreeze

haha fug i am so confused.

What can I do to help?

thank you.
i just purged the server and did a fresh reinstall.
everything is better now. but about to make a new post!