Fixing sqlite3 on Windows for Rails

Environment

What I tried

Running gem install sqlite3 complained that sqlite3 was missing. Uninstalling the gem:

gem uninstall sqlite3
Successfully uninstalled sqlite3-1.3.13-x64-mingw32

and reinstalling via gem install sqlite3 --platform=ruby still failed.

Solution

It turned out to be a bad combination of versions and sqlite3_native.so.

  1. Uninstall the gem again:
gem uninstall sqlite3
  1. Download the ZIPs from the SQLite download page: sqlite-dll-win32-x86-XXXXXXX.zip and sqlite-amalgamation-XXXXXXX.zip. Unzip the amalgamation package somewhere convenient (we will compile it later).
  2. Extract sqlite3.dll and place it in a directory that is on your PATH (where ruby.exe lives).
  3. Run:
gem install sqlite3 -v "=1.3.7" --platform=ruby -- --with-sqlite3-include=C:\temp\sqlite-amalgamation-3240000 --with-sqlite3-lib=C:\Ruby25-x64\bin

(Adjust the paths if you extracted the sources elsewhere.)

Notes