Fixing sqlite3 on Windows for Rails
- #Rails
- #SQLite
- #Troubleshooting
- #Tips
- 2018/08/25
Environment
- Ruby 2.5.1
- Ruby on Rails 5.1
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.
- Uninstall the gem again:
gem uninstall sqlite3
- Download the ZIPs from the SQLite download page:
sqlite-dll-win32-x86-XXXXXXX.zipandsqlite-amalgamation-XXXXXXX.zip. Unzip the amalgamation package somewhere convenient (we will compile it later). - Extract
sqlite3.dlland place it in a directory that is on your PATH (whereruby.exelives). - 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
- You need the DevKit (a C compiler) to build the native extension.
- The issue apparently does not happen on Ruby 2.4.
- Watch out for proxies. If needed, create
~/.gemrcand sethttp_proxy: http://proxyserver:port.
Share:
X (Twitter)