0

I have Ruby 2.4 and trying to install mysql2 . I follow the instructions from internet:

  1. gem uninstall mysql2 - if needed;
  2. download mysql connector;
  3. gem install mysql2 --platform=ruby -- '--with-mysql-lib="C:\conn\lib" --with-mysql-include="C:\conn\include"' and see message - 1 gem is installed;
  4. copy file libmysql.lib to rubyFolder/bin

If run rails s I see this message:

Could not find mysql2-0.4.8-x64-mingw32 in any of the sources Run bundle install to install missing gems.

and I do it - bundle, but after that, if I run again rails s I see same error:

C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require': cannot load such file -- mysql2/2.4/mysql2 (LoadError)

I am using Windows. One solution is to switch to Ruby 2.3, but is there way to use mysql2 with Ruby 2.4 ?

gdfgdfg
  • 3,181
  • 7
  • 37
  • 83
  • Have you included `mysql2` **in the `Gemfile`**? You do not need to install the library locally via `gem install`; you need to install it as part of the project's dependencies - i.e. include it in the `Gemfile`, and then run `bundle install`. – Tom Lord Oct 13 '17 at 15:39
  • Yes, it is in GemFile - `gem 'mysql2'` . This is ruby 2.4 with MySQL2, I follow steps from here: https://stackoverflow.com/questions/28925628/ruby-on-rails-cannot-load-such-file-mysql2-2-2-mysql2-loaderror and it is not working. Still same error. – gdfgdfg Oct 13 '17 at 16:21
  • Have you found a solution for this? Or you have downgraded the Ruby to 2.3 ? – UnahD Dec 03 '17 at 16:44

0 Answers0