cannot load such file -- mysql2/2.4/mysql2 (LoadError) - windows
There is no mysql2 binary for Ruby 2.4 for Windows available at this time. So i uninstall ruby 2.4 and install ruby 2.3. Now it is working well
Ruby on Rails - cannot load such file -- mysql2/2.2/mysql2 (LoadError)
The problem is that the mysql2
gem is not installing with its native dependencies. In previous versions of Ruby, this would have triggered the unable to build native gem extension
error:
Something has changed in Ruby 2.2
so that you can install the gem without it building the native extension. This does not mean the problem is resolved however - and so you have to ensure you install the gem with the appropriate dependencies.
Tutorial:
Download C-Connector from MYSQL (note your version of Ruby -- if you're using 64 bit, download the 64 bit version)
Unzip / Install the MYSQL C-Connector folder onto your HDD (don't have any spaces in the path)
Run the following command:
gem install mysql2 --platform=ruby -- '--with-mysql-dir="C:/your-mysql-connector-path"'
This should install the gem with the files it needs
Then you can copy
libmysql.dll
fromC:/your-mysql-connector-path
-> c:/your-ruby-install/bin`
The difference between this install and the previous one will be that this should mention that the native gem extensions are being installed (This could take a while
), which suggests that Ruby is looking at the library.
This time, if it installs correctly, it should work for you.
--
If you're still seeing an error, you'll have to uninstall any existing versions of the mysql2
gem on your system:
If you're getting an error, you just need to type gem uninstall mysql2
, select all
and then repeat the steps above.
rake aborted! cannot load such file -- mysql2/mysql2 on El Capitan
This problem does ring a bell, but instead of digging out the Internet and my memory, I have just tried the following: Install the latest mysql2
of the 0.3 series (0.3.20 at time of writing), and bundle it up for the application.
The problem seems that the latest mysql2
gem version 0.4 is not compatible with Rails 3.
Your gem versions cannot be changed, and you want to have the same versions as production. To do so, you could just copy over your Gemfile.lock
file from the production server, put it in your local folder aside the Gemfile
, and execute the bundle install
command.
Note that if your Gemfile
specifies:
gem 'mysql2', '> 0.3'
Then Bundler will install the latest version that matches 0.n
where n >= 3
. At time of writing, that leads Bundler to get a 0.4
version, which is not compatible with your Rails version (Bundler cannot infer that from your Gemfile
). A workaround for you is to modify your copy of the Gemfile
(and committing it to your project may be a good idea):
gem 'mysql2', '> 0.3.13' # put here the actual version used in production
Doing so, Bundler will install a version matchings 0.3.n
, with n >= 13
.
Rails Server not Working (LoadErrror mysql2) Windows
The following below instructions can help you.
gem uninstall mysql2
Download last MySQL connector from http://cdn.mysql.com/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip
Extract it to C:\connector-6.0.2
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"
Related Topics
Aws Cognito User Authentication Missing Required Parameter Srp_A
Check Method Call on Model Using Minitest
Ruby on Rails Routing Matching Username
Interested in What the "<<" Does
How to Merge Consecutive Repeating Elements in an Array
React Error (Only a Reactowner Can Have Refs.)
Gem Install Cannot Find a Header File
Redirect_Uri_Mismatch. Login with Google Using Ruby on Rails
What Can a Ruby Symbol (Syntax) Contain
Ruby: Ssl_Connect Syscall Returned=5 Errno=0 State=Unknown State (Openssl::Ssl::Sslerror)
Generate Nested Hashes from Strings and Deep Merging in Ruby