Error “…cannot load such file — mysql2/2.0/mysql2 (LoadError)”. On Windows XP with Ruby 2.0.0

☆樱花仙子☆ 提交于 2019-11-27 09:05:53

Had the absolutely same issue on Windows 7 x64 with Ruby 2.0.0 and DevKit 4.7.

The following steps helped me.

  1. gem uninstall mysql2

  2. Download last MySQL connector from http://cdn.mysql.com/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip

  3. Extract it to C:\connector-6.0.2

  4. gem install mysql2 --platform=ruby -- '--with-mysql-lib="C:\connector-6.0.2\lib" --with-mysql-include="C:\connector-6.0.2\include" --with-mysql-dir="C:\connector-6.0.2"'

Or even shorter:

gem install mysql2 --platform=ruby -- --with-opt-dir="C:\connector-6.0.2"

uninstall mysql2-0.3.11-x86-mingw32, gems compiled before Ruby200 won't work. You have to compile it yourself. If you run gem uninstall mysql2 and there is a non compiled version listed then just uninstall mysql2-0.3.11-x86-mingw32 - the compiled version else...

Installation gem install mysql2 --platform=ruby. that would work.

Follow this guide on installing devkit http://rubyonwindowsguides.github.com/book/ch02-04.html.

Then try again.

Exactly the same behavior when I try to install Redmine on windows XP

  • when I try to do the "rake generate_secret_token", I got "cannot load such file -- mysql2/2.0/mysql2 (LoadError)"
  • and when I try to re build mysql2 using --platform=ruby, I got the same message as you green.

for the moment, I am stucked there ... but if anybody has anything to allow me to move forward, it will be very welcome. I will keep informed as well

antoine

I almost done the same what @odiszapc described. Uninstall old gem, download mysql-connector-c-noinstall, unzip, but finally I used this command to build native gem:

gem install mysql2 --platform=ruby -- --with-opt-dir=/c/connector-6.0.2

(If you use git-bash then you can use unix style directory syntax.)

matsoor

Copy paste from that link: https://github.com/brianmario/mysql2/issues/359. It worked for me.


If after installing the gem, you get an error:

"The specified module could not be found.
C:/Devel/Ruby200/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11/lib/mysql2/mysql2.so"

That can be fixed by copying libmysql.dll to Ruby's bin folder.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!