mysql ruby-on-rails macos gem mysql2

No se ha podido instalar la gema mysql2 OS X Mountain Lion



ruby-on-rails macos (3)

Soy nuevo con RoR y estoy tratando de instalar Mysql2 -v ''0.3.11''. Tengo OS X Mountain Lion, rieles 3.2.6, ruby ​​1.9.3.

Debajo está el error que recibo. Miré a todas partes y no encontré nada.

$gem install mysql2 -v ''0.3.11'' Building native extensions. This could take a while... ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. /Users/curiosity/.rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb checking for rb_thread_blocking_region()... yes checking for rb_wait_for_single_fd()... yes checking for mysql.h... yes checking for errmsg.h... yes checking for mysqld_error.h... yes creating Makefile make compiling client.c In file included from client.c:1: In file included from ./mysql2_ext.h:8: In file included from /Users/curiosity/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/ruby.h:32: /Users/curiosity/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/ruby/ruby.h:105:37: error: ''ruby_check_sizeof_long'' declared as an array with a negative size typedef char ruby_check_sizeof_long[SIZEOF_LONG == sizeof(long) ? 1 : -1]; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/curiosity/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/x86_64-darwin12.0.0/ruby/config.h:24:21: note: expanded from macro ''SIZEOF_LONG'' #define SIZEOF_LONG 8 ^ In file included from client.c:1: In file included from ./mysql2_ext.h:8: In file included from /Users/curiosity/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/ruby.h:32: /Users/curiosity/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/ruby/ruby.h:109:38: error: ''ruby_check_sizeof_voidp'' declared as an array with a negative size typedef char ruby_check_sizeof_voidp[SIZEOF_VOIDP == sizeof(void*) ? 1 : -1]; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/curiosity/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/x86_64-darwin12.0.0/ruby/config.h:28:22: note: expanded from macro ''SIZEOF_VOIDP'' #define SIZEOF_VOIDP 8 ^ In file included from client.c:1: In file included from ./mysql2_ext.h:8: In file included from /Users/curiosity/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/ruby.h:32: In file included from /Users/curiosity/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/ruby/ruby.h:1377: In file included from /Users/curiosity/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/ruby/intern.h:34: /Users/curiosity/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/ruby/st.h:67:45: error: ''st_check_for_sizeof_st_index_t'' declared as an array with a negative size typedef char st_check_for_sizeof_st_index_t[SIZEOF_VOIDP == (int)sizeof(st_index_t) ? 1 : -1]; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/curiosity/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/x86_64-darwin12.0.0/ruby/config.h:28:22: note: expanded from macro ''SIZEOF_VOIDP'' #define SIZEOF_VOIDP 8 ^ 3 errors generated. make: *** [client.o] Error 1 Gem files will remain installed in /Users/curiosity/.rvm/gems/ruby-1.9.3-p125/gems/mysql2-0.3.11 for inspection. Results logged to /Users/curiosity/.rvm/gems/ruby-1.9.3-p125/gems/mysql2-0.3.11/ext/mysql2/gem_make.out

Gracias por tu ayuda.


Estás usando RVM en lugar del Ruby que viene con 10.8. Bueno. Ahora, deja de usar el MySQL que viene con 10.8.

Instalar y actualizar Homebrew . Ahora corre

brew install mysql

Usa el /Gemfile en tu proyecto para instalar la gema mysql2 . Añadir

gem "mysql2"

a su /Gemfile . Luego actualiza tu aplicación con Bundler ejecutando

bundle install

Permita que los administradores de paquetes (Homebrew y Bundler) trabajen para usted.

Esto debería solucionar los problemas que tienes.


Yo también obtengo el mismo tipo de error en mac10.10 y uso los siguientes comandos que funcionan para mí:

  1. Instale y actualice Homebrew usando:

    brew install mysql

  2. Ejecute el archivo Install gem Mysql usando:

    joya instalar mysql2 -v ''0.3.11''

  3. Ejecutar la instalación del paquete


Como dijo Deefour , tuve que usar RVM. La respuesta va para él, simplemente no pude comentar su respuesta. +1

Pero rvm exec bundle install me dio un error:

rvm do bundle install se eliminó, utilice rvm 1.9.2,1.9.3 do bundle install o rvm all do bundle install lugar.

Utilicé sudo rvm all do bundle install y todo salió perfecto a partir de ese momento.