Il comando rails server
getta questo errore.errore "... non può caricare tale file - mysql2/2.0/mysql2 (LoadError)". Su Windows XP con Ruby 2.0.0
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)
Io uso Rubino 2.0.0 da RubyInstaller sulla scatola di Windows XP.
ho capito qual è il problema, ma non so come risolverlo. Il problema è che non v'è alcuna 2.0/
directory nel mysql2-0.3.11-x86-mingw32
gemma. Questa è la gemma che rails
installa come la sua dipendenza dal Gemfile:
GEM
remote: https://rubygems.org/
specs:
... many gems here
mysql2 (0.3.11-x86-mingw32)
... many gems here
DEPENDENCIES
...
mysql2
...
Questo è ciò che è in quel mysql2.rb
di file:
# 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
E 'ovvio che ci vuole l'attuale numero di versione Ruby e usa come il segmento di percorso per raggiungere una certa lima mysql2
. In effetti è il file mysql2.so
. Come io uso Rubino 2.0.0 il segmento del percorso è 2.0
:
mysql2/2.0/mysql2
Ok, ora vediamo come quella directory di mysql2-0.3.11-x86-mingw32
gemma assomiglia:
dir: C:\Ruby200\lib\ruby\gems\2.0.0\gems\mysql2-0.3.11-x86-mingw32\lib\mysql2\
No qualsiasi 2.0/
directory.
Conosco il problema relativo a libmysql.dll. Ce l'ho nel mio C:\Ruby200\bin
. Non aiuta
Ho letto questa risposta https://stackoverflow.com/a/5368767/1114926 dal creatore di RubyInstaller. Ci ho provato ma non è stato d'aiuto. Funziona per Ruby 1.9.3
perché c'è la directory 1.9/
. Ma non funziona per Ruby 2.0.0
.
Come risolverlo?
UPD 1:
Grazie per la vostra answer. Ho provato. Purtroppo non ho ERROR: Failed to build gem native extension.
errore:
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...
Dice:
You have to install development tools first.
Ma io ho piena DevKit installato, RubyInstaller lo installa. Non riesco a capire cos'altro ha bisogno.
Ho già inviato un problema a mysql2
pagina GitHub https://github.com/brianmario/mysql2/issues/364. Nessuna risposta ancora.
Grazie per la risposta. Si prega di consultare il mio aggiornamento. – Green
Questo ha funzionato per me. Grazie mille :) –