luislavena / mysql-gem

MySQL/Ruby Bindings, wrapped as Gem with improved cross-platform support
http://rubyforge.org/projects/mysql-win
Other
53 stars 20 forks source link

require error on Windows with Ruby 2.0.0p0 #15

Closed Conky5 closed 11 years ago

Conky5 commented 11 years ago
C:\>ruby -v
ruby 2.0.0p0 (2013-02-24) [i386-mingw32]

C:\>gem list

*** LOCAL GEMS ***

bigdecimal (1.2.0)
bundler (1.3.4)
io-console (0.4.2)
json (1.7.7)
minitest (4.3.2)
mysql (2.9.1 x86-mingw32)
psych (2.0.0)
rake (0.9.6)
rdoc (4.0.0)
rubygems-update (2.0.3)
test-unit (2.0.0.0)

C:\>irb
DL is deprecated, please use Fiddle
irb(main):001:0> require 'mysql'
LoadError: cannot load such file -- mysql/mysql_api
        from C:/RubyAuto/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
        from C:/RubyAuto/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
        from C:/RubyAuto/lib/ruby/gems/2.0.0/gems/mysql-2.9.1-x86-mingw32/lib/mysql.rb:6:in `rescue in <top (required)>'
        from C:/RubyAuto/lib/ruby/gems/2.0.0/gems/mysql-2.9.1-x86-mingw32/lib/mysql.rb:2:in `<top (required)>'
        from C:/RubyAuto/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `require'
        from C:/RubyAuto/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `rescue in require'
        from C:/RubyAuto/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:35:in `require'
        from (irb):1
        from C:/RubyAuto/bin/irb:12:in `<main>'
luislavena commented 11 years ago

In RubyInstaller 2.0.0 release notes:

https://groups.google.com/d/topic/rubyinstaller/mg5ailNICvM/discussion

 Existing pre-compiled gems are not Ruby 2.0 compatible 

Ruby 2.0 introduces ABI breakage which means compiled C extensions with previous 
1.9.3 will work with Ruby 2.0. 

DO NOT install Ruby 2.0 on top of existing Ruby 1.9.3, or try to use compiled 
extensions with it. 

You will be required to force compilation of those gems: 

    gem install <name> --platform=ruby 

This will require you have the extra dependencies required for that gem to 
compile. Look at the gem documentation for the requirements. 

This is similar to luislavena/sqlite3-ruby#82

You can force compilation by adding --platform=ruby during gem installation

Refer to the following post on how to use Connector/C to compile mysql gem:

http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/