Problemas al instalar la gema mysql2 en Mac OS Maverics

User icon Crysfel VillaCalendar icon Jan 30, 2014Calendar iconwork,ruby,rails

Problemas al instalar la gema mysql2 en Mac OS Maverics

He adquirido una MacBook Pro con Mac OS Maverics y comencé a instalar mi ambiente de desarrollo para poder seguir actualizando mi sitio Quizzpot.com, primero instale MySQL utilizando el instalador oficial, luego instale RVM para descargar ruby-1.9.3 que es la versión que actualmente utilizo en Quizzpot.com, cuando intente descargar e instalar las gemas que utilizo me encontre con el siguiente problema.

$ bundle install
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /Users/crysfel/.rvm/rubies/ruby-1.9.3-p484/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
creating Makefile

make  clean

make
compiling client.c
In file included from client.c:1:
In file included from ./mysql2_ext.h:8:
In file included from /Users/crysfel/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/ruby.h:32:
/Users/crysfel/.rvm/rubies/ruby-1.9.3-p484/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/crysfel/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/x86_64-darwin13.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/crysfel/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/ruby.h:32:
/Users/crysfel/.rvm/rubies/ruby-1.9.3-p484/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/crysfel/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/x86_64-darwin13.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/crysfel/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/ruby.h:32:
In file included from /Users/crysfel/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/ruby/ruby.h:1383:
In file included from /Users/crysfel/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/ruby/intern.h:43:
/Users/crysfel/.rvm/rubies/ruby-1.9.3-p484/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/crysfel/.rvm/rubies/ruby-1.9.3-p484/include/ruby-1.9.1/x86_64-darwin13.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

make failed, exit code 2

Gem files will remain installed in /Users/crysfel/.rvm/gems/ruby-1.9.3-p484@quizzpot/gems/mysql2-0.3.13 for inspection.
Results logged to /Users/crysfel/.rvm/gems/ruby-1.9.3-p484@quizzpot/extensions/x86_64-darwin-13/1.9.1/mysql2-0.3.13/gem_make.out
An error occurred while installing mysql2 (0.3.13), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.13'` succeeds before bundling.

La solución fue desinstalar la versión que tenía de MySQL de la siguiente manera.

sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/MySQL*
edit /etc/hostconfig and remove the line MYSQLCOM=-YES-
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /var/db/receipts/com.mysql.*

E instalar MySQL utilizando Hombrew, que es un administrador de paquetes y dependencias para Mac OS, como no tenía instalado esta herramienta la instalé de la siguiente manera:

$ ruby -e "$(curl -fsSL <https://raw.github.com/Homebrew/homebrew/go/install>)"

Lo siguiente fue instalar MySQL:

$ brew install mysql

Y luego iniciar el servidor.

$ mysql.server start

Bastante sencillo realmente, y por último intentar nuevamente el bundle install. Esto resolvió el problema y las dependencias se instalaron correctamente!

Happy coding!

Te ayudo a mejorar al entrevistar, únete a mi lista de correo.

Unirse

Te mando historias y consejos para mejorar tu carrera como Ingeniero de Software, también hablo sobre finanzas personales e inversiones.

Crysfel's Twitter accountCrysfel's Linkedin accountCrysfel's Youtube channel

También estoy en Youtube

Publico videos en Youtube de vez en cuando, suscríbete a mi canal.

©2023 ALL RIGHTS RESERVED CRYSFEL'S BLOG