How to Install Sqlite3 For Ruby on Windows

Install sqlite3 for Ruby on Rails

So the only way i got to install sqlite3 is by running RailsInstaller (http://railsinstaller.org/en). It installs the whole bundle of programs for Ruby on Rails app though.

How do I install sqlite3 for Ruby on Windows?

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:

  1. Install the Ruby Devkit for your setup (DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe for me since I use a x64 machine)
  2. Download and extract the autoconf package from Sqlite.org
  3. Run msys.bat (it is inside the ruby devkit root folder)
  4. cd into the path where you downloaded the sqlite source (for example: "cd /c/dev/sqlite3" for path "c:\dev\sqlite3" if you are new to MSYS/MINGW32)
  5. Run "./configure"
  6. Run "make"
  7. Run "make install"
  8. Get the sqlite3 gem again, this time specifying the platform and the 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 given in step 4)

  9. Check the Gemfile.lock of your rails app and make sure that it points to the correct sqlite3 version. 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.

Ruby sqlite3 gem installation issue on Windows 10

adding gem 'sqlite3', git: "https://github.com/larskanis/sqlite3-ruby", branch: "add-gemspec" in the project Gemfile file works. After that run bundle install. Make sure to install git in the machine. This is the github link

Installing SQLite3 for Ruby on Windows - what's the current easiest route?

The Windows version of Ruby on Rails does not ship with the Sqlite3 database, even though the database.yaml configuration file is preconfigured to use Sqlite.

This is a how to guide on how to install Sqlite3 on your Windows PC. This article assumes that you already have Ruby and Ruby on Rails installed on your PC.

First you will need to download two files from the Sqlite web site http://www.sqlite.org/download.html:

sqlite-3_5_9.zip (214.32 KiB)
A command-line program for accessing and modifing SQLite databases.
See the documentation for additional information.

sqlitedll-3_5_9.zip (213.17 KiB)
This is a DLL of the SQLite library without the TCL bindings.
The only external dependency is MSVCRT.DLL.

The first file is the Sqlite command line program used for modifing the Sqlite database. You may or may not use this.

The second file is the Windows DLL library file and Ruby uses this when Rails makes Sqlite database calls.

When both these ZIP files have been extracted you should have the following files:

  • sqlite3.exe
  • sqlite3.def
  • sqlite3.dll

Copy these file to the bin directory of your Ruby installation, if you followed the default Ruby installation it will be located here:

C:\ruby\bin

Now that you have the Sqlite3 files installed you need to tell Ruby how to use them. To do this you need to download the Ruby bindings for Sqlite3.
Fortunately this is easy to do, using Ruby gems. Simply at the command prompt type the following command:

gem install sqlite3-ruby

You will now need to tell Gems which version you need as you will be presented with the following output:

Bulk updating Gem source index for: http://gems.rubyforge.org
Select which gem to install for your platform (i386-mswin32)
1. sqlite3-ruby 1.2.2 (mswin32)
2. sqlite3-ruby 1.2.2 (ruby)
3. sqlite3-ruby 1.2.1 (mswin32)
4. sqlite3-ruby 1.2.1 (ruby)
5. Skip this gem
6. Cancel installation
>_

Please select option 1, sqlite3-ruby 1.2.2 (mswin32). All being successful you will get some output like this:

Successfully installed sqlite3-ruby-1.2.2-mswin32
Installing ri documentation for sqlite3-ruby-1.2.2-mswin32...
Installing RDoc documentation for sqlite3-ruby-1.2.2-mswin32...

If you are using Rails 2+ you should be able to run the following rake tasks from your Rails application directory. For example say you created a Rails application located here: C:\MyApp you should be able to execute:

C:\MyApp>rake db:create
or
C:\MyApp>rake db:migrate

Good luck !

(This was taken verbatim from http://blog.emson.co.uk/2008/06/installing-sqlite3-on-windows-for-rails/)

gem install sqlite3 on Windows errors out with missing function dlopen

my issue fixed after running this command

ridk exec pacman -S mingw-w64-x86_64-dlfcn

before running gem install sqlite3


Reference: https://github.com/sparklemotion/sqlite3-ruby/issues/248



Related Topics



Leave a reply



Submit