While building a web application using ruby on rails you may get the following error when running rake db:migrate
rake db:migrate rake aborted! no such file to load -- sqlite3 (See full trace by running task with --trace)
My environment is a centos 5.3 linux server running rails 2.2.2 and the project was created using ‘rails projectname’ defaults to the sqlite driver. Yum confirmed that I have sqlite installed.
rpm -q sqlite sqlite-3.3.6-2
We must be missing the sqlite gem
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
checking for fdatasync() in -lrt... yes
checking for sqlite3.h... no
make
make: *** No rule to make target `ruby.h', needed by `sqlite3_api_wrap.o'. Stop.
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
This error is caused by the lack of the sqlite-devel package so install it as follows.
yum install sqlite-devel
Once again install the sqlite gem
gem install sqlite3-ruby
That’s all, now you’re back on track.
rake db:migrate (in /home/headfirst/tickets) == CreateTickets: migrating ================================================== -- create_table(:tickets) -> 0.0095s == CreateTickets: migrated (0.0103s) =========================================