web-dev-qa-db-ja.com

MySQL Ruby GemをUbuntu9.10にインストールする方法は?

Ruby Gem for MySQLのインストールで問題が発生しました。これは、実行しているコマンドです。

Sudo gem install mysql

これは私が得ている出力です:

Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
    ERROR: Failed to build gem native extension.

/usr/bin/Ruby1.8 extconf.rb
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... yes
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=/usr/bin/Ruby1.8
    --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 /usr/lib/Ruby/gems/1.8/gems/mysql-2.8.1 for inspection.
Results logged to /usr/lib/Ruby/gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out

これをインストールするには、何をする必要がありますか?

10
Andrew

おかげで このスレッド インストールに失敗する理由は

...パッケージがコンパイルされたときに間違った方向を指しているパス。

ありがたいことに、解決策は非常に簡単です。

Sudo gem uninstall mysql
Sudo apt-get install libmysqlclient-dev -y
Sudo gem install mysql 

注:mysqlをアンインストールしようとするとエラーメッセージが表示されましたが、そもそもインストールされていなかったので問題ありません。 mysql gemのインストール中に、エラーのようなメッセージが表示されました:No definition for next_result、しかしそれらはエラーではありません。これは、ドキュメントをインストールするときに発生します。これらは、特定の機能に使用できるドキュメントがないことを示す単なるメッセージです。

27
Andrew

RubyでMySQLを使用するために、そのgemは実際には必要ありません。 Debian/Ubuntuには、同じコードがすでにコンパイルおよび準備されているパッケージがあります。 Sudo apt-get install libmysql-Rubyと入力するだけです。

4
whitequark

Ubuntu Hardy、8.04では、apt-getインストールを使用できます。

Sudo apt-get install libmysqlclient15-dev -y
4
stcorbett