コマンドrails server
はこのエラーをスローします。
C:/Ruby200/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/mysql2.rb:2:in `require': cannot load
such file -- mysql2/2.0/mysql2 (LoadError)
Windows XPボックスのRubyInstallerからRuby 2.0.0を使用しています。
何が問題なのかはわかりましたが、解決方法がわかりません。問題は、 gem2.0/
にディレクトリがないことです。mysql2-0.3.11-x86-mingw32
これは、依存関係としてGemfilerails
からインストールされるgemです。
GEM
remote: https://rubygems.org/
specs:
... many gems here
mysql2 (0.3.11-x86-mingw32)
... many gems here
DEPENDENCIES
...
mysql2
...
これはそのmysql2.rb
ファイルにあるものです:
# C:\Ruby200\lib\ruby\gems\2.0.0\gems\mysql2-0.3.11-x86-mingw32\lib\mysql2\mysql2.rb
RUBY_VERSION =~ /(\d+.\d+)/
require "mysql2/#{$1}/mysql2" # <<-- this is that #2 line that throws an error
現在の Ruby バージョン番号を取得し、それをパス セグメントとして使用してmysql2
ファイルに到達することは明らかです。実はmysql2.so
ファイルです。Ruby 2.0.0を使用しているため、パス セグメントは2.0
次のとおりです。
mysql2/2.0/mysql2
それでは、mysql2-0.3.11-x86-mingw32
gemのディレクトリがどのように見えるか見てみましょう。
dir: C:\Ruby200\lib\ruby\gems\2.0.0\gems\mysql2-0.3.11-x86-mingw32\lib\mysql2\
2.0/
ディレクトリはありません。
libmysql.dllに関する問題を知っています。私はそれを持っていC:\Ruby200\bin
ます。役に立ちません。
RubyInstaller の作成者からこの回答https://stackoverflow.com/a/5368767/1114926を読みました。試してみましたが、役に立ちませんでした。ディレクトリRuby 1.9.3
があるので動作します。1.9/
しかし、それは機能しませんRuby 2.0.0
。
それを解決する方法は?
更新 1:
ご回答ありがとうございます。私はもう試した。残念ながら、私はERROR: Failed to build gem native extension.
エラーがあります:
C:\>gem install mysql2 --platform=ruby
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
C:/Ruby200/bin/ruby.exe extconf.rb
checking for rb_thread_blocking_region()... *** 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.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=C:/Ruby200/bin/ruby
C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:431:in `try_do': The compiler failed to generate an executable file. (Runtim
eError)
You have to install development tools first.
... other code follows here...
それは言います:
最初に開発ツールをインストールする必要があります。
しかし、完全な DevKit がインストールされており、RubyInstaller によってインストールされます。他に何が必要なのか理解できません。
既にmysql2
GitHub ページhttps://github.com/brianmario/mysql2/issues/364に問題を投稿しました。まだ答えはありません。