Ruby 2.0.0 – Rails 4.0 に SQLite3 をインストールしたときのメモ [Windows]

Windows7 64bit に Ruby 2.0.0, Rails 4.0, SQLite3をインストールしたときのメモ。

環境

  1. Windows 7 64bit
  2. [Ruby]: 2.0.0 – rubyinstaller-2.0.0-p247-x64.exe
  3. [gem]: 2.0.3 – rubyinstaller-2.0.0-p247-x64.exe
  4. [DevKit]: 4.7.2 – DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe
  5. [Rails]: 4.0 – gem install rails –platform=ruby
  6. [SQLite3]: 3.7.17 – sqlite-autoconf-3071700.tar.gz

失敗例

“gem install sqlite3” だけではインストール出来ませんでした。

C:\Ruby\DevKit64>gem install sqlite3
Fetching: sqlite3-1.3.7.gem (100%)
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.

C:/Ruby/Ruby200-x64/bin/ruby.exe extconf.rb
checking for sqlite3.h... no<br />sqlite3.h is missing. Install SQLite3 from http://www.sqlite.org/ first.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.

成功例

下記のサイトのページ中央付近の「sqlite3の差し替え」を参考にさせて頂きました。

参考1: (Windows) Ruby2.0 on Rails で SQLite3 にハマらない手順

生成されたsqlite3.exeをruby/binに設置し、再度 “gem install sqlite3” を実行すると…。
(環境変数にDevKit/binを登録しbashを使用、SQLite3は「sqlite-autoconf-3071700.tar.gz」を使用)

C:\sqlite3\sqlite-autoconf-3071700>bash
$ ./configure --prefix=c:/sqlite3
$ make
$ make install
$ cp c:/sqlite3/bin/* c:/Ruby/Ruby200-x64/bin/.
$ exit
C:\sqlite3\sqlite-autoconf-3071700>gem install sqlite3 --platform=ruby -- --with-sqlite3-include=c:/sq
lite3/include --with-sqlite3-lib=c:/sqlite3/lib
Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-sqlite3-include=c:/sqlite3/include --wi
th-sqlite3-lib=c:/sqlite3/lib'
This could take a while...
Successfully installed sqlite3-1.3.7
Parsing documentation for sqlite3-1.3.7
unable to convert "\x90" from ASCII-8BIT to UTF-8 for lib/sqlite3/sqlite3_native
.so, skipping<br />Installing ri documentation for sqlite3-1.3.7
1 gem installed

C:\sqlite3\sqlite-autoconf-3071700>gem search --local sqlite3

*** LOCAL GEMS ***

sqlite3 (1.3.7)

sqlite3 がインストールできたようです。

だが、サーバーが立ち上がらない

sqlite3 はインストールできたはずですが、以下のエラーメッセージが表示されサーバーが立ち上がりませんでした。

“Specified ‘sqlite3’ for database adapter, but the gem is not loaded. Add gem ‘sqlite3’ to your Gemfile.”

Ruby2.0 Rails4.0 Sqlite3

ちょっと今回はWindowsでRuby2.0はここまでにしようかな…。

Ubuntu使ってみようかな…。

と考え中。

再挑戦 2013.9.8

解決している人を発見し再挑戦しました。

参考2: “Add ‘gem sqlite3” to your Gemfile” – Ruby Forum
手順

プロジェクトフォルダ内の[Gemfile.lock]を開き、

sqlite3 (1.3.8-x86-mingw32)

sqlite3 (1.3.8-x64-mingw32)

と変更し、上書き保存します。これだけです。
(sqlite3をインストールし直したら、1.3.7 → 1.3.8になっていました)

サーバーを立ち上げてみます。
$ rails s

Ruby on Rails Welcome aboard - Opera

動いているようです。

Ruby 2.0.0 – Rails 4.0 に SQLite3 をインストールしたときのメモ [Windows]」への3件のフィードバック

  1. […] このエラーの原因としては、どうもバグっぽい。Windows上でRuby(64Bit)を使っているときにおこる?みたい。 解決法としては、以下2つを行います。 ・Gemfile.lockの修正 ・sqlite3のインストール (参考)Ruby 2.0.0 – Rails 4.0 に SQLite3 をインストールしたときのメモ [Windows] | superabl… […]

コメントを残す