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

后端 未结 5 1893
时光取名叫无心
时光取名叫无心 2020-12-01 18:54

The command rails server throws this error.

C:/Ruby200/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/mysql2.rb:2:in `require\':          


        
相关标签:
5条回答
  • 2020-12-01 19:32

    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.

    0 讨论(0)
  • 2020-12-01 19:35

    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

    0 讨论(0)
  • 2020-12-01 19:46

    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.)

    0 讨论(0)
  • 2020-12-01 19:48

    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"

    0 讨论(0)
  • 2020-12-01 19:51

    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.

    0 讨论(0)
提交回复
热议问题