Being really new to Ruby/Rails, and after attempting to resolve the issue myself this weekend I'm making an attempt to seek advice here.
I have a complete Ruby/Apache/Passenger setup done on FreeBSD, and I'm trying to accomplish the task of using Windows as a Ruby development environment.
So far:
- Ruby is installed, v2.0.0p0 (2013-02-24) [x64-ming32]
- Rails is installed, v.3.2.12
- I have the Ruby dev kit installed and registered.
- I have the sqlite3 dll/exe copied to the Ruby "bin" folder (which is also in my path using the "Start Command Prompt with Ruby" console.)
- I can start a rails server successfully, and continuing with the http://guides.rubyonrails.org/getting_started.html tutorial to 3.3.
">rake db:create" tells me:
Please install the sqlite3 adapter:
gem install activerecord-sqlite3-adapter
( sqlite3 is not part of the bundle. Add it to Gemfile.)
which I have no "understanding" of. Trying to install activerecord-sqlite3-adapter gives me a "Could not find a valid gem..."
">gem install sqlite3" returns:
Building native extensions. This could take a while...
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.
D:/Development/Ruby200-x64/bin/ruby.exe extconf.rb
checking for sqlite3.h... *** extconf.rb failed ***
Right now I'm stuck at the point where I don't even know what state my Ruby on Windows installation is in. I'm trying to follow the main Rails tutorial and it doesn't specify any of these issues (probably because Ruby on Windows seems to be a natural pain for a lot of people.)
What am I missing?!? I'm just trying to install sqlite3 for Ruby on Windows, seems simple right?
If I do ">rais db"
the SQLite shell is presented:
SQLite version 3.7.15.2 2013-01-09 11:53:05
Similar questions with steps that do not resolve my issue: Installing SQLite 3.6 On Windows 7
Even though the question has been answered, I want to post my research to help others. I found a lot of information online, but being a Ruby newbie I had a tough time following all. The basic answer comes from the following post https://github.com/luislavena/sqlite3-ruby/issues/82 with instructions by "paulwis" on how to properly install sqlite3 for ruby 2.0.0-p0 and some comments on https://github.com/rails/rails/issues/10150 . So here it is:
Get the sqlite3 gem again, this time specifying the platform and the path to the newly compiled binaries:
For example:
(from the paths given in step 4)
Hope this helps someone.
I was able to install sqlite3 with ruby2.0.0 on win XP32 with following command:
c:\>gem install sqlite3 --platform=ruby -- --with-sqlite3-dir=C:/distr/sqlite --with-sqlite3-include=C:/distr/sqlite
Folder
C:/distr/sqlite
contains following filesSo, basically I've extract
sqlite-amalgamation-3071602.zip
andsqlite-dll-win32-x86-3071602.zip
toC:/distr/sqlite
.HEADS UP
You still need to put copy of
sqlite3.dll
andsqlite3.def
somewhere to PATH. IMHO it's best to keep sqlite3 binaries in ruby's bin folder.The easiest way to get set up for Ruby on Rails on a Windows machine is by using the RailsInstaller, which automatically installs and configures sqlite3 for you. One step.
http://railsinstaller.org/en
Get the fat binary from here
https://ci.appveyor.com/project/MSP-Greg/sqlite3-ruby/build/3/job/hhk6ie8gdo545svr/artifacts
and
For windows, go to
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/sqlite3-1.3.13-x64-mingw32/lib/sqlite3.rb
and make sure
require "sqlite3"
instead of native