Mysql2 gem Unable to create custom extensions

Our computer is having problems installing gem mysql2. We just upgraded his computer from OS X 10.6 to 10.8 (Mountain Lion). I tried installing mysql through homebrew and through the 64-bit DMG installer. I also tried symbolic bindings to dev tools (as indicated here: Failed to set some gems after updating the mountain lion ). We have Xcode (4.4) installed and command line tools installed. We tried to restart the computer after installing the command line tools.

This is his PATH declaration from ~/.bashrc :

 PATH=/usr/local/bin:$PATH:$HOME/.rvm/bin:/usr/local/mysql/bin # Add RVM to PATH for scripting 

Symlink:

 Diego-Blantons-MacBook-Pro-3:~ lmrunner07$ sudo ln -s /usr/bin/llvm-gcc-4.2 /usr/bin/gcc-4.2 Password: 

Try installing gem:

 Diego-Blantons-MacBook-Pro-3:~ lmrunner07$ gem install mysql2 Building native extensions.  This could take a while... ERROR:  Error installing mysql2:  ERROR: Failed to build gem native extension.    /Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/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 /Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby.h:32,        from ./mysql2_ext.h:8,        from client.c:1: /Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/ruby.h:105: error: size of array 'ruby_check_sizeof_long' is negative /Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/ruby.h:109: error: size of array 'ruby_check_sizeof_voidp' is negative In file included from /Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/intern.h:34,        from /Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/ruby.h:1382,        from /Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby.h:32,        from ./mysql2_ext.h:8,        from client.c:1: /Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/st.h:67: error: size of array 'st_check_for_sizeof_st_index_t' is negative client.c: In function 'rb_raise_mysql2_error': client.c:98: warning: ISO C90 forbids mixed declarations and code client.c: In function 'rb_mysql_client_socket': client.c:590: warning: ISO C90 forbids mixed declarations and code make: *** [client.o] Error 1 Gem files will remain installed in /Users/lmrunner07/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11 for inspection. Results logged to /Users/lmrunner07/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/ext/mysql2/gem_make.out 

I uninstalled the homebrew installed by mysql as well as the startup agent. Also rm -rf gem directory (Users / lmrunner07 / .rvm / gems / ruby-1.9.3-p194 / gems / mysql2-0.3.11)

+7
source share
6 answers

I solved this:

Note. When I tried to build, I had a problem with the library, Library not loaded: libmysqlclient.18.dylib , which was fixed when running sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib (see Library not loaded: libmysqlclient.16.dylib when trying to start the "rails" server in OS X 10.6 using gem mysql2 if you get the same problem.)

+5
source

You tried:

 gem install mysql2 --with-mysql-config=/usr/lib64/mysql/mysql_config 

Replace /usr/lib64/mysql/mysql_config with the location of your mysql configuration.

0
source

Unfortunately, the installation process is very segmented, and it is difficult to isolate what might be your problem without looking at your steps in general.

Without knowing more about your installation steps, here are a few notes that I followed and I got a stable version of Rails Mountain Lion (again, apologies for not being more specific).

  • Instructions for RVM, Ruby: moncefbelyamani.com

    Note. Here were certain steps that I took with suggestions from brew doctor and 'rvm requirements' , which I NEVER used in previous settings.

    Notes:

    • Xcode 4.3+ uses only ruby-1.9.3-p125 + (and tell you if I have problems compiling to upgrade to Xcode 4.1)
    • Using brew install autoconf automake apple-gcc42
    • Using brew tap homebrew/dupes
    • And others...
  • Rails Special Instructions: railsapps.github.com

  • For mysql (go to mysql install part: coolestguyplanettech.com

Note. I took an optional step: ... to use mysql commands without entering the full path to the commands you need to add to the mysql directory in my shell path ... since I found this could help during build and so .d. (some scenarios suggest ...)

Here, I tried to simply create a new rails application with the default database being mysql (which knocked out mysql2 via bundler). From there - I tried to make a test application with a quick scaffold - and mysql2 barfed.

From there, I find the error "The library is not loaded: libmysqlclient.16.dylib" and, as indicated here: https://stackoverflow.com/a/166269/2322/2000/2000.jpg I added this line to my .profile: export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH

MY PATH explicitly contains rails and rubies: /Users/gabriel/.rvm/gems/ ruby-1.9.3-p194@rails327 /bin:/Users/gabriel/.rvm/gems/ ruby-1.9.3-p194@global /bin:/Users/gabriel/.rvm/rubies/ruby-1.9.3-p194/bin:/Users/gabriel/.rvm/bin:/usr/local/mysql/bin:/usr/local/bin:/usr/bin:/usr/sbin:/opt/X11/bin:

We hope these resources provide additional help.

0
source

I managed to assemble it by doing: PATH = / bin: / usr / bin: / opt / mysql5_64 / bin gem install mysql2 Where mysql5_64 I downloaded the latest 64-bit version of mysql and it was extracted there. Leaving my already installed mysql databases intact.

0
source

I was able to fix this with implode -ing rvm and install Ruby Homebrew. Then, gem mysql2 is installed just fine.

This is not the first problem I have encountered with rvm. I don’t think I will use it again.

0
source

I successfully worked on OSX Yosemite:

 sudo port install mysql56 gem install mysql2 -- --with-mysql-config=/opt/local/lib/mysql56/bin/mysql_config 
0
source

All Articles