How to install sqlite3 for Ruby on Windows?

Being really new to Ruby / Rails, and after trying to solve the problem myself this weekend, I am trying to ask for advice here.

I have a full installation of Ruby / Apache / Passenger on FreeBSD, and I'm trying to complete the task of using Windows as my Ruby development environment.

Still:

  • Ruby installed, v2.0.0p0 (2013-02-24) [x64-ming32]
  • Rails installed, v.3.2.12
  • I have installed and registered Ruby Dev Kit.
  • I have sqlite3 dll / exe copied to the Ruby "bin" folder (which is also in my path using the "Run command line with Ruby" console.)
  • I can successfully start the rails server and continue from the tutorial http://guides.rubyonrails.org/getting_started.html to version 3.3.
  • "> rake db: create" tells me:

    Please install the gem install activerecord-sqlite3-adapter : gem install activerecord-sqlite3-adapter (sqlite3 is not included. Add it to the Gemfile.)

which I have no "understanding". Trying to install the activerecord-sqlite3 adapter gives me "Could not find the correct gem ..."

  • "> gem install sqlite3" returns:

    Building native extensions. This could take a while... Building native extensions. This could take a while... Building native extensions. This could take a while... 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 a point where I don’t even know what state my Ruby installation on Windows is in. I am trying to follow a basic Rails tutorial and it does not identify any of these problems (perhaps because Ruby on Windows seems to be a natural pain for many people.)

What am I missing?!? I'm just trying to install sqlite3 for Ruby on Windows, it seems simple, right?

If I do ">rais db" the SQLite shell will be presented:

SQLite version 3.7.15.2 2013-01-09 11:53:05

Similar questions with steps that do not solve my problem: Install SQLite 3.6 on Windows 7

+35
windows ruby ruby-on-rails sqlite sqlite3
Mar 18 '13 at 15:21
source share
10 answers

Although the question has been answered, I want to publish my research to help others. I found a lot of information on the Internet, but as a newbie to Ruby, I had to keep track of everyone. The main answer comes from the following message https://github.com/luislavena/sqlite3-ruby/issues/82 with instructions "paulwis" on how to correctly install sqlite3 for ruby ​​2.0.0-p0 and some comments on https: //github.com/rails/rails/issues/10150 . So here it is:

  • Install Ruby Devkit for your installation (DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe for me since I am using an x64 machine)
  • Download and extract the autoconf package from Sqlite.org
  • Run msys.bat (it is located in the ruby ​​devkit root folder)
  • cd to the path where you downloaded the sqlite source (for example: "cd / c / dev / sqlite3" for the path "c: \ dev \ sqlite3" if you are new to MSYS / MINGW32)
  • Run "./configure"
  • Run make
  • Run "make install"
  • Get the sqlite3 gem again, this time specifying the platform and path to the newly compiled binaries:

     gem install sqlite3 --platform=ruby -- --with-sqlite3-include=[path\to\sqlite3.h] --with-sqlite3-lib=[path\to\sqlite3.o] 

    For example:

     gem install sqlite3 --platform=ruby -- --with-sqlite3-include=/c:/dev/sqlite3/ --with-sqlite3-lib=/c:/dev/sqlite3/.libs/ 

    (from the paths shown in step 4)

  • Check the Gemfile.lock of your rails application and make sure it points to the correct version of sqlite3. The mine was "sqlite3 (1.3.7-x86-mingw32)" and manually changed it to "sqlite3 (1.3.7-x64-mingw32)." Removing the platform also works: "sqlite3 (1.3.7)".

Hope this helps someone.

+74
Apr 15 '13 at 19:14
source share

I was able to install sqlite3 with ruby2.0.0 on win XP32 using the following command:

c:\>gem install sqlite3 --platform=ruby -- --with-sqlite3-dir=C:/distr/sqlite --with-sqlite3-include=C:/distr/sqlite

The C:/distr/sqlite folder contains the following files

  • shell.c
  • sqlite3.c
  • sqlite3.h
  • sqlite3ext.h
  • sqlite3.def
  • sqlite3.dll

So basically I extract sqlite-amalgamation-3071602.zip and sqlite-dll-win32-x86-3071602.zip in C:/distr/sqlite .

HEADS UP

You still need to put a copy of sqlite3.dll and sqlite3.def somewhere in your PATH. IMHO it is better to store the sqlite3 binaries in the ruby ​​bin folder.

+11
May 13 '13 at 14:31
source share
 #!/usr/bin/env sh mkdir c:/sqlite3x86 wget -P c:/sqlite3x86 http://packages.openknapsack.org/sqlite/sqlite-3.7.15.2-x86-windows.tar.lzma cd c:/sqlite3x86 bsdtar --lzma -xf c:/sqlite3x86/sqlite-3.7.15.2-x86-windows.tar.lzma gem install sqlite3 --platform=ruby -- --with-opt-dir=c:/sqlite3x86 cd c:/ rm -rf c:/sqlite3x86 
+1
Aug 09 '13 at 0:25
source share

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

+1
Jul 06 '18 at 11:37
source share

Get the binary file from here

https://ci.appveyor.com/project/MSP-Greg/sqlite3-ruby/build/3/job/hhk6ie8gdo545svr/artifacts

as well as

 gem install c:\path\to\downloaded_gem.gem 
+1
Jul 10 '18 at 7:53
source share

I thought I would answer - from the comments, for the sake of posterity. The problem was that I picked up a new version of Ruby / Rails (for Windows) that was not yet compatible with SQLite3.

I lowered the rating to 1.9.x and was able to complete all the actions.

0
Mar 21 '13 at 17:54
source share

The easiest way to configure Ruby on Rails on a Windows machine is to use RailsInstaller, which automatically installs and configures sqlite3 for you. One step.

http://railsinstaller.org/en

0
May 01 '17 at 18:17
source share
0
Apr 07 '19 at 23:07 on
source share

This is an old branch, but still relevant.

For us, it was as simple as editing a Gemfile and adding a specific version for sqlite:

 gem 'sqlite3', '~> 1.3.13 
0
May 10 '19 at 17:05
source share

I am going to answer this question again because one moderator mofo deleted my previous post. Any moderator reading this post understands:

-one
Apr 08 '19 at 17:02
source share



All Articles