in my mac OSX 10.6 32 bit, I can install mysql2 gem quite easily, but not in mini mac 10.6 64bit server.
I have installed MySQL 5.5.11 in troublesome server, while in my home mac MySQL 5.5.0.m2 Somehow when I run bundle install, in server it tries to install mysql2.0.3.2 while in home mysql2.0.2.6
Please don't tell me to
env ARCHFLAGS="-arch x86_64" sudo gem install mysql2 --version '= 0.2.6' -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
I tried that, doesn't work.
Included /usr/local/mysql/bin in $PATH does not help as well.
Error code:
Installing mysql2 (0.3.2) with native extensions /Users/administrator/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:533:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
/Users/administrator/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... 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
--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=/Users/administrator/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
--with-mysql-config
--without-mysql-config
Gem files will remain installed in /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.3.2 for inspection.
Results logged to /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.3.2/ext/mysql2/gem_make.out
from /Users/administrator/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:511:in `block in build_extensions'
from /Users/administrator/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:486:in `each'
from /Users/administrator/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:486:in `build_extensions'
from /Users/administrator/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:159:in `install'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/source.rb:96:in `install'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/installer.rb:55:in `block in run'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/spec_set.rb:12:in `block in each'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/spec_set.rb:12:in `each'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/spec_set.rb:12:in `each'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/installer.rb:44:in `run'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/installer.rb:8:in `install'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/cli.rb:225:in `install'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/vendor/thor/task.rb:22:in `run'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/vendor/thor.rb:246:in `dispatch'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/vendor/thor/base.rb:389:in `start'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/bin/bundle:13:in `<top (required)>'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/bin/bundle:19:in `load'
from /Users/administrator/.rvm/gems/ruby-1.9.2-p180/bin/bundle:19:in `<main>'
for people who didn't use brew to install mysql and use mysql 5.6 and higher:
according to this answer
you need to edit
mysql_config
which was placed in my case here:/usr/local/mysql-5.6.12-osx10.7-x86_64/bin
and change
cflags
andcxxflags
to:after this manipulations
goes flawlessly
This method is for Rails 3.1.0 (and hopefully up) on 64 bit machine. I used on Ruby-1.9.2-p180.
This blog answered it: http://www.tatvartha.com/2010/10/installing-mysql-gem-with-bundler-on-snow-leopard/
Basically, the method above: $ sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
may work, but without bundler.
To do it with bundler, first must run this on terminal:
Note "mysql2" not "mysql" as shown in that blog.
That adds a config to ~/.bundle/config file
Then add this to ~/.bash_profile:
That is the same with telling bundler to run the command on top of this post.
Posting this wherever I can--hopefully it will help someone and save them a lot of time.
I dug through 2 days worth of the internet and Stack Overflow, and it wasn't until I found this link and then starting working through this ticket for mysql2 that I actually resolved the issue.
With my setup (as explained in the ticket), the compiler switches of -Wno-null-conversion -Wno-unused-private-field would break and give me an error that wasn't exactly correct, which was:
I did a bundle install on a redmine repo and got the same error message :
Running Fedora 16 64 bits, all I did was install
mysql-devel
(development package) from the distro rpm and the problem was solved!So I think you could just
or apt-get the missing devel package.
For those on Fedora 21, and you already installed mysql-devel:
solved the problem for me. see: redhat docs
The only way I could get this to work was to install the x64 version of mysql. I just used the .dmg located here http://dev.mysql.com/downloads/mysql/ and it worked like a charm. Wish I could get the 4 hours back it took to figure this out.