Błąd „… nie można załadować takiego pliku - mysql2 / 2.0 / mysql2 (LoadError)”. W systemie Windows XP z Ruby 2.0.0
Komendarails server
zgłasza ten błąd.
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)
używamRuby 2.0.0 zRubyInstaller na Windows XP.
Zorientowałem się, jaki jest problem, ale nie wiem, jak go rozwiązać. Problem polega na tym, że nie ma żadnego2.0/
katalog wmysql2-0.3.11-x86-mingw32
klejnot. To klejnot, któryrails
instaluje jako zależność odGemfile:
GEM
remote: https://rubygems.org/
specs:
... many gems here
mysql2 (0.3.11-x86-mingw32)
... many gems here
DEPENDENCIES
...
mysql2
...
To właśnie w tym jestmysql2.rb
plik:
# 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
Jest oczywiste, że pobiera bieżący numer wersji Ruby i używa go jako segmentu ścieżki, aby dotrzeć do niektórychmysql2
plik. W rzeczywistości tak jestmysql2.so
plik. Jak używamRuby 2.0.0 segment ścieżki jest2.0
:
mysql2/2.0/mysql2
Ok, teraz zobaczmy, jak ten katalogmysql2-0.3.11-x86-mingw32
klejnot wygląda jak:
dir: C:\Ruby200\lib\ruby\gems\2.0.0\gems\mysql2-0.3.11-x86-mingw32\lib\mysql2\
Nie Obojętnie2.0/
informator.
Wiem o tym problemielibmysql.dll. Mam to w moimC:\Ruby200\bin
. To nie pomaga.
Przeczytałem tę odpowiedźhttps://stackoverflow.com/a/5368767/1114926 od twórcy RubyInstaller. Próbowałem, ale to nie pomogło. Działa naRuby 1.9.3
ponieważ tam jest1.9/
informator. Ale to nie działaRuby 2.0.0
.
Jak to rozwiązać?
UPD 1:
Dziękuję za twojeodpowiedź. Próbowałem. Niestety mamERROR: Failed to build gem native extension.
błąd:
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...
To mówi:
Najpierw musisz zainstalować narzędzia programistyczne.
Ale mam zainstalowany pełny program DevKit, RubyInstaller instaluje go. Nie mogę zrozumieć, czego jeszcze potrzebuje.
Wysłałem już problemmysql2
Strona GitHubhttps://github.com/brianmario/mysql2/issues/364. Brak odpowiedzi.