Downloaded RubyInstaller for Windows Ruby 2.2.1 and was amazed.
Where in the past simple gem installation had failed now it worked.
Is this a change in Ruby, the RubyInsaller for Windows, or RubyGems?
: ruby 2.2.1p85 (2015-02-26 revision 49769) [i386-mingw32]
C:\Users\Scott>gem list
*** LOCAL GEMS ***
bigdecimal (1.2.6)
io-console (0.4.3)
json (1.8.1)
minitest (5.4.3)
power_assert (0.2.2)
psych (2.0.8)
rake (10.4.2)
rdoc (4.2.0)
test-unit (3.0.8)
C:\Users\Scott>gem install sqlite3
Fetching: sqlite3-1.3.10-x86-mingw32.gem (100%)
Successfully installed sqlite3-1.3.10-x86-mingw32
Parsing documentation for sqlite3-1.3.10-x86-mingw32
Installing ri documentation for sqlite3-1.3.10-x86-mingw32
Done installing documentation for sqlite3 after 1 seconds
1 gem installed
C:\Users\Scott>gem list --local
*** LOCAL GEMS ***
bigdecimal (1.2.6)
io-console (0.4.3)
json (1.8.1)
minitest (5.4.3)
power_assert (0.2.2)
psych (2.0.8)
rake (10.4.2)
rdoc (4.2.0)
sqlite3 (1.3.10 x86-mingw32)
test-unit (3.0.8)
C:\Users\Scott>gem install sinatra
Fetching: rack-1.6.0.gem (100%)
Successfully installed rack-1.6.0
Fetching: tilt-1.4.1.gem (100%)
Successfully installed tilt-1.4.1
Fetching: rack-protection-1.5.3.gem (100%)
Successfully installed rack-protection-1.5.3
Fetching: sinatra-1.4.5.gem (100%)
Successfully installed sinatra-1.4.5
Parsing documentation for rack-1.6.0
Installing ri documentation for rack-1.6.0
Parsing documentation for tilt-1.4.1
Installing ri documentation for tilt-1.4.1
Parsing documentation for rack-protection-1.5.3
Installing ri documentation for rack-protection-1.5.3
Parsing documentation for sinatra-1.4.5
Installing ri documentation for sinatra-1.4.5
Done installing documentation for rack, tilt, rack-protection, sinatra
after 731
seconds
4 gems installed
But my joy was short-lived:
C:\Users\Scott>irb
irb(main):001:0> require ‘sqlite3’
LoadError: cannot load such file – sqlite3/sqlite3_native
from
C:/ruby2.2.1-p85/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb
:54:in require' from C:/ruby2.2.1-p85/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb :54:in
require’
from
C:/ruby2.2.1-p85/lib/ruby/gems/2.2.0/gems/sqlite3-1.3.10-x86-mingw3
2/lib/sqlite3.rb:6:in rescue in <top (required)>' from C:/ruby2.2.1-p85/lib/ruby/gems/2.2.0/gems/sqlite3-1.3.10-x86-mingw3 2/lib/sqlite3.rb:2:in
<top (required)>’
from
C:/ruby2.2.1-p85/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb
:128:in require' from C:/ruby2.2.1-p85/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb :128:in
rescue in require’
from
C:/ruby2.2.1-p85/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb
:39:in require' from (irb):1 from C:/ruby2.2.1-p85/bin/irb:11:in
’
irb(main):002:0>
Any ideas?
I had the same problem and decided to compile the extension myself. In
the end it turned out to be quite easy:
Download the SQLite source amalgamation from
SQLite Download Page
unpack the source in a directory of your choice (e.g. C:\sqlite3)
be sure to have the Ruby DevKit installed and enabled the DevKit
environment
compile the DLL, I used following command:
gcc -Os -O2 -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_RTREE
-DSQLITE_ENABLE_COLUMN_METADATA --shared sqlite3.c -o sqlite3.dll
copy the DLL to a directory in your PATH, I copied it to
C:\Ruby22\bin
install the gem with following command:
gem install sqlite3 --platform=ruby – --with-sqlite3-include=C:/sqlite3
–with-sqlite3-lib=C:/sqlite3
Done
I also compiled the sqlite3.exe with the command:
gcc -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -Os -O2
-DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_RTREE
-DSQLITE_ENABLE_COLUMN_METADATA shell.c sqlite3.c -o sqlite3.exe
Hello Scott,
after reading
https://groups.google.com/forum/#!msg/sqlite3-ruby/cNqvONJmocU/C0Rdg6ZxhV4J
I think this an issue with the sqlite3 gem. Looks like it doesn’t
include the proper sqlite3_native.so for Ruby 2.2. I think we have to
give Luis a little bit of time to update the gem for 2.2.
Thanks Gunter!
I shall have to try that.
I ended up downloading and extracting the most recent knapsack version
of sqlite and using that, similar to what I did in my earlier post:
https://www.ruby-forum.com/topic/4413168
Running:
Windows 7 Professional with SP1
64-bit Operating System
Based upon the directions at the following link:
opened 04:54PM - 16 Oct 13 UTC
closed 05:21PM - 16 Oct 13 UTC
Hello Rubygems team, please look into the following, as referenced from. I hope … you can fix this. ( https://github.com/rails/rails/issues/12559 )
# The Problem
If you install `rails 4.0.0` on Ruby 2.0.0 64-bit/32-bit on Windows 8 64-bit and create an application, you will run into:
```
Specified 'sqlite3' as the database adapter, but the gem is not loaded.
Add `gem 'sqlite3' to your Gemfile.
```
Even when (by default) `gem sqlite3` has been added to your gemfile.
Bundle install does not show `sqlite3`, but gem list will show `sqlite3 (1.3.8)`. It even shows up in your lock file.
# The Workaround
- **Download the DevKit and install**
- For 64 bit, download [this](http://packages.openknapsack.org/sqlite/sqlite-3.7.15.2-x64-windows.tar.lzma) package by Luis Lavena ([source](http://stackoverflow.com/a/16707867/715669))
- For other platforms there are similar packages on knapsack
- Extract to a location like 'C:\sqlite3'
- `gem install sqlite3 --platform="ruby" -- --with-opt-dir="C:\sqlite3"`
Your Gemfile.lock now says both or only the last line:
```
sqlite3 (1.3.8)
sqlite3 (1.3.8-x86-mingw32)
```
Both are wrong. Remove the former and change the latter to
```
sqlite3 (1.3.8-x64-mingw32)
```
For 32-bit windows, this is not the case, obviously.
- run `bundle list`
- it now says `sqlite 1.3.8`
- cheer
Sidenote: The double `-- --` makes everything behind the first `--` be copied to the devkit
# The part where I weep
This works, until a different platform joins your development process. `sqlite3 for mac` works just fine. Once this person `bundle install`s, the `Gemfile.lock` is updated to include the `sqlite3 (1.3.8)` which precedes the `sqlite3 (1.3.8-x64-mingw32)` version.
- You have to manually remove it everytime someone bundle updates and NOT commit it into the repo.
# What I think happens
I believe the `sqlite3` gem **says** or **reports** it works with windows, while it needs a native build. So it will install the actually not working version and use that over the native build version. This is why `gem list` does show the gem (it IS installed) but `bundle list` won't, since it's NOT loaded into the rails environment, as it doesn't work.
The workaround is tedious and this fix is not something someone 'just finds' by googling. Most solutions out there are so random and invole copying dll's or having 12 steps.
Created a knapsack directory.
Downloaded the file sqlite-3.7.15.2-x64-windows.tar.lzma and extracted
in the knapsack directory using:
bsdtar --lzma -xf sqlite-3.7.15.2-x64-windows.tar.lzma
Then ran:
gem install sqlite3 --platform=ruby – --with-opt-dir=C:\knapsack
Of course, 3.7.15 is not the latest version of SQLite, but I guess
beggars can’t be choosers.
I just wish I knew what was going on.
Is this a problem with Ruby? A problem with the gem program? A problem
with the sqlite3 RubyGem?