Rubino gemma mysql2 installare in mancanza
Domanda
Quando provo ad installare la gemma mysql2, non riesce senza errori apparenti. Qualcuno sa cosa fare per ovviare a questo così mysql2 installazioni?
$ 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
Soluzione
Bisogna avere 64 bit MySQL installato sulla vostra macchina, più gli strumenti di costruzione si ottiene quando si installa Xcode.
Altri suggerimenti
Ubuntu:
sudo apt-get install libmysqlclient-dev #(mysql development headers)
sudo gem install mysql2 -- --with-mysql-dir=/etc/mysql/
Questo è tutto!
Risultato:
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
È necessario le intestazioni di sviluppo di MySQL per mysql2 correttamente la compilazione. Ciò è necessario, perché gran parte delle funzionalità è scritto in C e successivamente collegati contro MySQL.
Una soluzione è quella di uno dei punti del programma di installazione gemma al mysql cartella di installazione in modo esplicito in questo modo
gem install mysql2 -- --with-mysql-dir=/usr/local/mysql
# or where ever you installed your mysql server to
o con l'installazione di un server MySQL in una posizione nota (ad esempio utilizzando homebrew .) E quindi l'installazione di la gemma
# install the mysql server locally
brew install mysql
# install the gem
gem install mysql2
Entrambi gli approcci richiedono di avere installato XCode di avere il compilatore GCC richiesta.
Con Brew e MySQL installati, ho usato il seguente per installare la gemma mysql2
gem install mysql2 -- --with-mysql-config=/usr/local/Cellar/mysql/5.5.10/bin/mysql_config
Se stai usando Bundler, si può dire bundler di questo con il comando:
bundle config build.mysql2 --with-mysql-config=/usr/local//Cellar/mysql/5.5.10/bin/mysql_config
Come documentato qui: http://gembundler.com/man/bundle-config. 1.html
su Mac OS X Mountain Lion, sotto il comando ha funzionato per me:
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
Output:
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
Si potrebbe voler controllare questa discussione presso il sito web di MySQL: http: / /forums.mysql.com/read.php?116,178217,178217 , in particolare la risposta di Scott Derrick: http://forums.mysql.com/read.php?116,178217,189357#msg-189357
Per essere più precisi, provare a utilizzare
sudo gem install mysql2 -- --with-mysql-dir=/usr/local/mysql
La speranza che aiuta.
Ho scavato attraverso 2 giorni vale la pena di internet e Stack Overflow, e non è stato fino a quando ho trovato questo link e poi iniziare a lavorare attraverso questo biglietto per mysql2 che ho effettivamente risolto il problema.
Con il mio setup (come spiegato nel biglietto), il compilatore commuta di -Wno-null-conversione -Wno-inutilizzato-privato-campo si rompono e mi danno un errore che non era esattamente corretta, che era:
mysql.h is missing. please check your installation of mysql and try again
Credo che se si digita rvm use ruby-2.1.0@rails4.0 --create
in voi directory allora bundle install
funziona.
ho risolto questo essendo specifica su dove sono le directory, senza bisogno di reinstallare nulla , con birra o MacPorts o qualsiasi altra cosa, semplicemente specificando in cui sono le cose (solo una cosa: il rubino su il mio mac è stato installato con rvm, non sto usando quella predefinita che viene fornito con OS x):
di aggiungere al vostro gem install mysql2
le bandiere sotto
-
--srcdir="..."
- il include -
--with-mysql-dir="..."
- la directory mysql -
--with-mysql-config="..."
- il file mysql_config
come questo gem install mysql2 --srcdir=/usr/local/mysql/include/ --with-mysql-dir=/usr/local/mysql --with-mysql-config=/usr/local/mysql/bin/mysql_config
In CentOS 6.x (7 dovrebbe funzionare) con SCL (collezione di software) 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