2

It's strange the I can install mysql2 with this command: $ gem install mysql2 --platform=ruby -- '--with-mysql-lib="c:\Program Files\MySQL\MySQL Server 5.5\lib" --with-mysql-include="c:\Program Files\MySQL\MySQL Server 5.5\include"' Following is the results:

Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
Successfully installed mysql2-0.3.10
1 gem installed
Installing ri documentation for mysql2-0.3.10...
Installing RDoc documentation for mysql2-0.3.10...

But when I'm running bundle install (apperently I have a lot of gems needs to install), it is failed to install mysql2, so bundle install stopped there, that really drives me crazy... anyone could help? a tons of thanks! Below is the result from bundle install:

Installing mysql2 (0.3.8) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension
.

        c:/Ruby192/bin/ruby.exe extconf.rb
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... no
checking for main() in -llibmysql... no
*** 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=c:/Ruby192/bin/ruby
        --with-mysql-dir
        --without-mysql-dir
        --with-mysql-include
        --without-mysql-include=${mysql-dir}/include
        --with-mysql-lib
        --without-mysql-lib=${mysql-dir}/lib
        --with-libmysqllib
        --without-libmysqllib


Gem files will remain installed in G:/Desktop/20090319-/Rails Examples/ClockingI
T/vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.8 for inspection.
Results logged to G:/Desktop/20090319-/Rails Examples/ClockingIT/vendor/bundle/r
uby/1.9.1/gems/mysql2-0.3.8/ext/mysql2/gem_make.out
An error occured while installing mysql2 (0.3.8), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.8'` succeeds before bundling.
aaron
  • 1,951
  • 3
  • 27
  • 41
  • Looks like Bundler is trying to install mysql2 version 0.3.8, but the windows versions for 0.3.8 have been yanked, as far as I can see. I'm a bit confused, since it should be the same behaviour for 0.3.10, but you can try to give the Gemfile an explicit version anyways. Like `gem 'mysql2', '0.3.10'` or `gem 'mysql2', '0.3.9'`. I'd have chosen the latter one, because it has an official x86-mingw32 version. – tbuehlmann Nov 23 '11 at 13:11

4 Answers4

8

On my ubuntu machine, had to run apt-get install libmysqld-dev first, then gem install mysql2 ... it worked like a charm :)

Gijs
  • 5,201
  • 1
  • 27
  • 42
Xander
  • 955
  • 1
  • 11
  • 15
2

Try this installing mysql from outside the bundle and if it works remove mysql from Gemfile

 sudo gem install mysql --no-rdoc --no-ri -- 

--with-mysql-config=/usr/local/mysql/bin/mysql_config

Also

apt-get install libmysqld-dev
Mithun Sasidharan
  • 20,572
  • 10
  • 34
  • 52
  • I tried `gem install mysql`, it succeed, but when I'm running `bundle install`, error happens again: Installing mysql2 (0.3.7) with native extensions Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. c:/Ruby192/bin/ruby.exe extconf.rb checking for rb_thread_blocking_region()... yes checking for main() in -llibmysql... no *** extconf.rb failed *** – aaron Nov 25 '11 at 02:15
0

Works fines, please download the version mysql-connector-c-6.1.5-win32, unzip on the folder, and try this.

Works well for me.

gem install mysql2 --no-ri --no-rdoc --platform=ruby -- --with-mysql-include=C:\mysql-connector\mysql-connector-c-6.1.5-win32\include --with-mysql-lib=C:\mysql-connector\mysql-connector-c-6.1.5-win32\lib

0

The version of mysql2 gem you're trying to install have issues on Windows.

Please install mysql2 gem without indicating the version:

gem install mysql2
Mithun Sasidharan
  • 20,572
  • 10
  • 34
  • 52
  • running `gem install mysql2`, I got this error: ERROR: While executing gem ... (NameError) uninitialized constant Psych::Syck – aaron Nov 25 '11 at 02:16
  • now that u have installed the mysql directly u can remove the mysql from the fgem file and then bundle install ok!!! That must suffice – Mithun Sasidharan Nov 25 '11 at 06:13
  • thanks, I removed using `gem uninstall mysql` and `gem uninstall mysql2`, and then ran `bundle install`, all gems are ok and I can see mysql2 is installed too `Installing mysql2 (0.2.6)`. But when I ran `rake db:migrate`, i got problem again: `libmysql.dll not found` problem and I fixed by copying `libmysql.dll` to `c:\Ruby192\bin` from `C:\Program Files\MySQL\MySQL Server 5.5\lib` then I ran `rake db:migrate`, got another problem: `rake aborted! 193: %1 is not a valid Win32 application. - c:/Ruby192/lib/ruby/gems/1.9.1/gem s/mysql2-0.2.6-x86-mingw32/lib/mysql2/1.9/mysql2.so` – aaron Nov 27 '11 at 03:42
  • fixed the `%1 is not a valid Win32 application` problem referring to this link http://stackoverflow.com/questions/1208029/193-1-is-not-a-valid-win32-application-bug-with-a-new-rails-application. new problem happens again... `ERROR: ActiveRecord oracle_enhanced adapter could not load ruby-oci8 library`, call stack: `c:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-oracle_enhanced-adapter-1.3.2/l ib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:7:in `res cue in '` – aaron Nov 27 '11 at 07:10