Frage

Wenn ich versuche, das mysql2 Juwel zu installieren, scheitert es ohne offensichtliche Fehler. Hat jemand wissen, was um diese so mysql2 installiert zu Arbeit tun?

$ 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
War es hilfreich?

Lösung

Sie haben 64-Bit-MySQL auf Ihrem Rechner installiert haben, sowie die Build-Tools erhalten Sie, wenn Sie Xcode installieren.

Andere Tipps

Ubuntu:

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

Das ist es!

Ergebnis:

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

Sie müssen die Entwicklung von MySQL-Header für mysql2 richtig zu kompilieren. Dies ist notwendig, weil ein großer Teil der Funktionalität in C geschrieben und anschließend verknüpfen gegen MySQL.

ist eine Lösung zu jedem Punkt des Edelstein Installationsprogramm auf den mysql explizit Installationsordner wie so

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

oder von einem MySQL-Server zu einem bekannten Ort der Installation (beispielsweise durch Verwendung homebrew .) Und dann die Installation die gem

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

Beiden Ansätze erfordern Sie XCode installiert haben, um den erforderlichen GCC Compiler haben.

Mit Brew und MySQL installiert ist, habe ich den Anschluss an die mysql2 gem

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

Wenn Sie Bündler verwenden, können Sie dazu sagen Bündler mit dem Befehl:

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

Wie dokumentiert hier: http://gembundler.com/man/bundle-config. 1.html

auf Mac OS X Mountain Lion, unter Befehl für mich gearbeitet:

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

Ausgabe:

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

Sie können diese Gewinde auf der MySQL-Website zu überprüfen: http: / /forums.mysql.com/read.php?116,178217,178217 , insbesondere die Antwort von Scott Derrick: http://forums.mysql.com/read.php?116,178217,189357#msg-189357

Um genauer zu sein, versuchen Sie es mit

sudo gem install mysql2 -- --with-mysql-dir=/usr/local/mysql

Ich hoffe, das hilft.

Ich grub bis 2 Tage im Wert des Internets und der Stack-Überlauf, und es war nicht, bis ich diesen Link und dann Anlaß arbeiten durch dieses Ticket für mysql2 , dass ich das Problem tatsächlich gelöst.

Mit meinem Setup (wie im Ticket erklärt), schaltet sich der Compiler von -Wno-null-Umwandlung -Wno-ungenutzt-private-Feld würde brechen und geben Sie mir einen Fehler, der nicht ganz richtig war, was war:

mysql.h is missing. please check your installation of mysql and try again

Ich denke, dass, wenn Sie rvm use ruby-2.1.0@rails4.0 --create in ihr Verzeichnis geben Sie dann bundle install es funktioniert.

ich dieses Problem gelöst durch spezifisch sind, wo sind die Verzeichnisse, keine Notwendigkeit, etwas neu zu installieren , mit brauen oder Macports oder was auch immer, nur durch die Angabe, wo sind die Dinge (nur eines: die Ruby on mein mac mit rvm installiert war, ich bin nicht den Standard eines verwenden, das mit o x kommt):

mit denen Sie Ihre gem install mysql2 die Flaggen unter

  • --srcdir="..." - das umfasst
  • --with-mysql-dir="..." - das Verzeichnis mysql
  • --with-mysql-config="..." - die mysql_config Datei

wie diese 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 funktionieren soll) mit SCL (Software-Sammlung) 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
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top