私の歴史と今

振り返ると恥ずかしくなるのが私の歴史。だけどそのときは真面目に書いていた訳でね。そんな今の私を書いていく。

Railsでmysql2.soがないと言われたら

以下のエラーが発生した。

C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/mysql2.rb:2:in `require': 126: 指定されたモジュールが見つかりません。   - C:/
Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/1.9/mysql2.so (LoadError)

libmysql.dllをPATHに通せばイイと書いてあったので入れたけど、以下のエラー

D:\RailsProjects\portal>rails g devise:install
C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/mysql2.rb:2:in `require': Incorrect MySQL client library version! This gem wa
s compiled for 6.0.0 but the client library is 5.5.12. (RuntimeError)

MySQL6.0なんてあったのか?と思ってググったら、Railsプロジェクトを作成した時にヒントが出力されているので見ろとのこと。
Railsプロジェクトを作成した時のヒントはこれ

======================================================================================================

  You've installed the binary version of mysql2.
  It was built using MySQL Connector/C version 6.0.2.
  It's recommended to use the exact same version to avoid potential issues.

  At the time of building this gem, the necessary DLL files where available
  in the following download:

  http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip/from/pick

  And put lib\libmysql.dll file in your Ruby bin directory, for example C:\Ruby\bin

======================================================================================================

なるほど、その通りしてみたらエラーは解消した。