简体   繁体   中英

OS X Lion with xampp + rails + mysql2 gem

I'm stuck trying to figure out how to get OS X Lion with a XAMPP installation's MySQL to work with the mysql2 gem in rails.

Here's what I've tried:

  • Installed the XAMPP Dev Kit
  • Installed mysql5-server with both port and brew. Both of which I've now uninstalled. As it didn't fix the problem.
  • Installed mysql5 community edition from DMG file. Now uninstalled as it didn't fix the problem.
  • Downloaded 32-bit version of mysql5 community edition as a tar. Extracted folder to '/var/mysql'

Here's the command I'm running to try and get it installed:

gem install mysql2 -- --with-mysql-dir=/var/mysql --with-mysql-include=
/var/mysql/include --with-mysql-lib=/var/mysql/lib --with-mysql-config=
/Applications/XAMPP/xamppfiles/bin/mysql_config

I'm at a loss how to get this to work. The only thing I can think of is that I'm somehow not pointing to the directories correctly. I've tried removing /include/, /mysql/ and /lib/ from the with-mysql-include, with-mysql-dir and with-mysql-lib configuration options. No luck with that. I've tried pointing those to the XAMPP installation. No luck still.

The error returned is:

ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.

/Users/user/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb --with-mysql-dir=/var/mysql --with-mysql-include=/var/mysql/include --with-mysql-lib=/var/mysql --with-mysql-config=/Applications/XAMPP/xamppfiles/bin/mysql_config
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for mysql.h... no
checking for mysql/mysql.h... no
-----
mysql.h is missing.  please check your installation of mysql and try again.
-----
*** 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
    --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=/Users/user/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
    --with-mysql-config


Gem files will remain installed in /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11 for inspection.
Results logged to /Users/user/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/ext/mysql2/gem_make.out

It'd be better not to bother with the stuff XAMPP provides, and to just install a fresh copy of MySQL, and simplify your Gem command for installing mysql2:

brew install mysql
gem install mysql2

You were getting errors with installing the gem after installing MySQL through Homebrew because of all this:

--with-mysql-dir=/var/mysql --with-mysql-include= \
/var/mysql/include --with-mysql-lib=/var/mysql/lib --with-mysql-config= \
/Applications/XAMPP/xamppfiles/bin/mysql_config

So removing it solves the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM