2011-01-06 8 views
47

Estoy tratando de instalar la gema mysql 2.8.1. Lo usaría para construir una aplicación Rails 2.0.2 en Ubuntu 10.04. Yo estaría usando Ruby 1.8.7. He instalado las dependencias de desarrollo (otras gemas). Por alguna razón, no puedo instalarlo. No puedo encontrar exactamente cómo solucionarlo. ¡¡Por favor ayuda!!Dificultades para instalar mysql gem en Ubuntu

me sale el siguiente en la terminal cuando intento instalarlo:

[email protected]:~/Downloads$ sudo gem install mysql-2.8.1.gem 
Building native extensions. This could take a while... 
ERROR: Error installing mysql-2.8.1.gem: 
    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 
[email protected]:~/Downloads$ 

Gracias por su ayuda !!

Respuesta

118

Prueba esto y luego instalar la gema mysql:

sudo apt-get install libmysqlclient-dev 

Si eso no es suficiente probarlo como esto

sudo apt-get install libmysqlclient-dev libmysqlclient16 ruby-dev 
+2

ruby-dev es opcional aquí libmysqlclient18 – xyzman

+27

intento si no está funcionando libmysqlclient16 – captainpete

+4

Trabajado para mí, pero no necesitaba instalar 'libmysqlclient *' en absoluto – hobs

2

Usted debe hacer lo que el mensaje de error que dice: comprobar el mkmf.log ! Busque este archivo usando find /usr/lib/ruby/gems/1.8/gems/ -name mkmf.log. Por lo general, este mensaje de error aparece porque olvidó instalar el paquete -dev para la extensión que estaba tratando de instalar. Entonces, si desea instalar la gema mysql, probablemente se le olvidó primero instalar libmysqlclient14-dev. Hacer una búsqueda apt-cache | grep dev para encontrar los paquetes apropiados.

cheque del PLZ this para más información

9

Prueba esto y luego instalar la gema mysql:

sudo apt-get install libmysqlclient-dev libmysqlclient16

Esto funcionó después luego corriendo sudo gem instala mysql.

La documentación no se instala correctamente (montones de errores "no hay una definición", aunque eso no es realmente algo grande.

paquete