joyau Ruby mysql2 installer à défaut
Question
Quand je tente d'installer la gemme mysql2, il échoue avec aucune erreur apparente. Est-ce que quelqu'un sait ce qu'il faut faire pour contourner ce donc mysql2 installations?
$ sudo gem install mysql2
Building 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
La solution
Vous devez avoir MySQL 64 bits installé sur votre machine, ainsi que les outils de construction que vous obtenez lorsque vous installez Xcode.
Autres conseils
Ubuntu:
sudo apt-get install libmysqlclient-dev #(mysql development headers)
sudo gem install mysql2 -- --with-mysql-dir=/etc/mysql/
Ca y est!
Résultat:
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
Vous devez les en-têtes de développement de MySQL pour mysql2 correctement à compiler. Cela est nécessaire, car une grande partie de la fonctionnalité est écrit en C et ensuite lié avec MySQL.
Une solution consiste à L'installateur de pierres précieuses à votre dossier d'installation mysql explicitement comme si
gem install mysql2 -- --with-mysql-dir=/usr/local/mysql
# or where ever you installed your mysql server to
ou en installant un serveur mysql à un emplacement connu (par exemple, en utilisant homebrew .), Puis d'installer la gemme
# install the mysql server locally
brew install mysql
# install the gem
gem install mysql2
Les deux approches vous avez besoin d'avoir installé XCode avoir le compilateur GCC nécessaire.
Avec Brew et MySQL installé, je l'utilise comme suit pour installer la gemme mysql2
gem install mysql2 -- --with-mysql-config=/usr/local/Cellar/mysql/5.5.10/bin/mysql_config
Si vous utilisez Bundler, vous pouvez dire Bundler à ce sujet avec la commande suivante:
bundle config build.mysql2 --with-mysql-config=/usr/local//Cellar/mysql/5.5.10/bin/mysql_config
Comme documenté ici: http://gembundler.com/man/bundle-config. 1.html
sur Mac OS X Mountain Lion, en dessous de commande a fonctionné pour moi:
gem install mysql2 -- --srcdir=/usr/local/mysql/include
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
Sortie:
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
Vous pouvez consulter ce fil sur le site web de MySQL: http: / /forums.mysql.com/read.php?116,178217,178217 , en particulier la réponse de Scott Derrick: http://forums.mysql.com/read.php?116,178217,189357#msg-189357
Pour être plus précis, essayez d'utiliser
sudo gem install mysql2 -- --with-mysql-dir=/usr/local/mysql
L'espoir qui aide.
Je creusé dans 2 jours la valeur de l'Internet et le débordement de pile, et il a fallu que je trouve ce lien puis travailler à partir par ce billet mysql2 que je réellement résolu le problème.
Avec ma configuration (comme expliqué dans le billet), le compilateur passe de -Wno null conversion -Wno-privé-utilisé-champ romprait et me donner une erreur qui n'a pas été tout à fait correct, ce qui était la suivante:
mysql.h is missing. please check your installation of mysql and try again
Je suppose que si vous tapez dans rvm use ruby-2.1.0@rails4.0 --create
vous répertoire bundle install
il fonctionne.
Je résolu ce problème en étant spécifique sur où sont les répertoires, pas besoin de réinstaller quoi que ce soit , avec bière ou macports ou autre, tout en spécifiant où sont les choses (une seule chose: le rubis sur mon mac a été installé avec RVM, je ne suis pas en utilisant la valeur par défaut qui est livré avec OS X):
ajouter à votre gem install mysql2
les drapeaux ci-dessous
-
--srcdir="..."
- includes -
--with-mysql-dir="..."
- le répertoire mysql -
--with-mysql-config="..."
- le fichier mysql_config
comme celui-ci gem install mysql2 --srcdir=/usr/local/mysql/include/ --with-mysql-dir=/usr/local/mysql --with-mysql-config=/usr/local/mysql/bin/mysql_config
Dans 6.x Centos (7 devrait fonctionner) avec SCL (collection de logiciels) 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