Instalacja Ruby Gem mysql2 nie powiodła się

Kiedy próbuję zainstalować Gem mysql2, nie udaje się bez widocznych błędów. Wie ktos co zrobic zeby to obejsc zeby mysql2 instalowal?

Tanner-Smiths-MacBook-Pro:Humans_vs_Zombies_Parse tanner$ sudo gem install mysql2Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
    ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** 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=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
    --with-mysql-config
    --without-mysql-config
    --with-mysql-dir
    --without-mysql-dir
    --with-mysql-include
    --without-mysql-include=${mysql-dir}/include
    --with-mysql-lib
    --without-mysql-lib=${mysql-dir}/lib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-mlib
    --without-mlib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-zlib
    --without-zlib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-socketlib
    --without-socketlib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-nsllib
    --without-nsllib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-mygcclib
    --without-mygcclib
    --with-mysqlclientlib
    --without-mysqlclientlib


Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/ext/mysql2/gem_make.out

Author: shilovk, 2010-11-06

11 answers

Musisz mieć zainstalowany 64-bitowy MySQL na komputerze, plus narzędzia do budowania, które otrzymujesz podczas instalacji xcode.

 26
Author: coreyward,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2010-11-06 21:03:50

Ubuntu:

sudo apt-get install libmysqlclient-dev  #(mysql development headers)
sudo gem install mysql2 -- --with-mysql-dir=/etc/mysql/
To jest to!

Wynik:

Building native extensions. This could take a while...
Successfully installed mysql2-0.2.6
1 gem installed
Installing ri documentation for mysql2-0.2.6...
Enclosing class/module 'mMysql2' for class Result not known
Enclosing class/module 'mMysql2' for class Client not known
Installing RDoc documentation for mysql2-0.2.6...
Enclosing class/module 'mMysql2' for class Result not known
Enclosing class/module 'mMysql2' for class Client not known
 144
Author: tunelko,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-05-21 15:36:19

Do poprawnej kompilacji mysql2 potrzebne są nagłówki programistyczne MySQL. Jest to konieczne, ponieważ duża część funkcjonalności jest napisana w języku C, a następnie powiązana z MySQL.

Rozwiązaniem jest albo skierowanie instalatora gem do folderu instalacyjnego mysql jawnie tak

gem install mysql2 -- --with-mysql-dir=/usr/local/mysql
# or where ever you installed your mysql server to

Lub instalując serwer mysql w znanej lokalizacji (np. używając homebrew).), a następnie zainstalowanie gem

# install the mysql server locally
brew install mysql
# install the gem
gem install mysql2

Oba podejścia wymagają zainstalowania XCode do posiadać wymagany kompilator GCC.

 38
Author: Holger Just,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2010-11-06 21:10:33

Z zainstalowanym Brew i MySQL, użyłem następujących do zainstalowania mysql2 gem

gem install mysql2 -- --with-mysql-config=/usr/local/Cellar/mysql/5.5.10/bin/mysql_config

Jeśli używasz Bundlera, możesz powiedzieć o tym bundlerowi za pomocą polecenia:

bundle config build.mysql2 --with-mysql-config=/usr/local//Cellar/mysql/5.5.10/bin/mysql_config

Jak udokumentowano tutaj: http://gembundler.com/man/bundle-config.1.html

 17
Author: dkam,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-02-19 12:32:07

Ubuntu 15.04:

sudo apt-get install libmysqlclient-dev
sudo gem install mysql2

Ubuntu-16.04:

sudo apt-get install ruby-mysql2
sudo gem install mysql2

Wyjście:

Building native extensions.  This could take a while...
Successfully installed mysql2-0.3.19
Parsing documentation for mysql2-0.3.19
Installing ri documentation for mysql2-0.3.19
Done installing documentation for mysql2 after 0 seconds
1 gem installed
 6
Author: shilovk,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-10-11 10:41:51

Na Mac OSX Moutain Lion, poniższe polecenie zadziałało dla mnie:

gem install mysql2 -- --srcdir=/usr/local/mysql/include
 5
Author: Sushma Satish,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-12-10 10:32:18

Możesz sprawdzić ten wątek na stronie MySQL: http://forums.mysql.com/read.php?116,178217,178217, szczególnie odpowiedź Scotta Derricka: http://forums.mysql.com/read.php?116,178217, 189357#msg-189357

Aby być bardziej szczegółowym, spróbuj użyć

sudo gem install mysql2 -- --with-mysql-dir=/usr/local/mysql
Mam nadzieję, że to pomoże.
 2
Author: rleber,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2010-11-06 21:04:31

Przekopałem się przez 2 dni w Internecie i przepełnienie stosu i dopiero gdy znalazłem TEN link, a następnie zacząłem pracować przez ten bilet dla mysql2, faktycznie rozwiązałem problem.

Z moją konfiguracją (jak wyjaśniono w paragonie), przełączniki kompilatora-wno-null-conversion-Wno-unused-private-field pękłyby i dały mi błąd, który nie był do końca poprawny, czyli:

mysql.h is missing. please check your installation of mysql and try again
 1
Author: AnthonyAlmighty,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-06-25 17:04:22

Domyślam się, że jeśli wpiszesz rvm use [email protected] --create do katalogu to bundle install to działa.

 0
Author: ,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-01-30 16:35:08

Rozwiązałem to poprzez określenie gdzie znajdują się katalogi, nie trzeba ponownie instalować czegokolwiek , z brew lub macports lub cokolwiek innego, po prostu określając gdzie są rzeczy (tylko jedna rzecz: ruby na moim Macu został zainstalowany z rvm, nie używam domyślnego, który jest dostarczany z os x):

Dodanie do twojego gem install mysql2 flagi poniżej

  • --srcdir="..." - zawiera
  • --with-mysql-dir="..." - katalog mysql
  • --with-mysql-config="..." - Plik mysql_config

Like this gem install mysql2 --srcdir=/usr/local/mysql/include/ --with-mysql-dir=/usr/local/mysql --with-mysql-config=/usr/local/mysql/bin/mysql_config

 0
Author: vic,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-10-21 17:05:45

W Centos 6.x (7 powinien działać) z SCL (software collection) rh-mysql:

scl enable rh-mysql56 bash
gem install mysql2 -v '0.4.5' -- --with-mysql-include=/opt/rh/rh-mysql56/root/usr/include --with-mysql-lib=/opt/rh/rh-mysql56/root/usr/lib64
 0
Author: Daniel Antonio Nuñez Carhuayo,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-11-26 04:24:29