ActiveState / activeruby

The Ruby Programming Language
https://www.ruby-lang.org/
Other
8 stars 7 forks source link

libmysql.dll is missing #4

Open Faelwen opened 7 years ago

Faelwen commented 7 years ago

My setup:

Description of the issue

If I try to connect to a mysql database using ActiveRecord with the following code (parameters anonymised):

require 'active_record'

ActiveRecord::Base.establish_connection(
  adapter: 'mysql2',
  host: 'XXX.XXX.XXX.XXX',
  port: 'XXXXX',
  username: 'XXXXXX',
  password: 'XXXXXX',
  database: 'XXXX'
)

I get the following error:

Failed to load libmysql.dll from libmysql.dll
["C:/ActiveRuby/lib/ruby/gems/2.3.0/gems/mysql2-0.4.8/lib/mysql2.rb:25:in `abort'", "C:/ActiveRuby/lib/ruby/gems/2.3.0/
ems/mysql2-0.4.8/lib/mysql2.rb:25:in `<top (required)>'", "C:/ActiveRuby/lib/ruby/2.3.0/rubygems/core_ext/kernel_requir
.rb:68:in `require'", "C:/ActiveRuby/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'", "C:/ActiveRub
/lib/ruby/gems/2.3.0/gems/activesupport-5.1.2/lib/active_support/dependencies.rb:292:in `block in require'", "C:/Active
uby/lib/ruby/gems/2.3.0/gems/activesupport-5.1.2/lib/active_support/dependencies.rb:258:in `load_dependency'", "C:/Acti
eRuby/lib/ruby/gems/2.3.0/gems/activesupport-5.1.2/lib/active_support/dependencies.rb:292:in `require'", "C:/ActiveRuby
lib/ruby/gems/2.3.0/gems/activerecord-5.1.2/lib/active_record/connection_adapters/mysql2_adapter.rb:5:in `<top (require
)>'", "C:/ActiveRuby/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'", "C:/ActiveRuby/lib/ruby/2.3.0
rubygems/core_ext/kernel_require.rb:68:in `require'", "C:/ActiveRuby/lib/ruby/gems/2.3.0/gems/activesupport-5.1.2/lib/a
tive_support/dependencies.rb:292:in `block in require'", "C:/ActiveRuby/lib/ruby/gems/2.3.0/gems/activesupport-5.1.2/li
/active_support/dependencies.rb:258:in `load_dependency'", "C:/ActiveRuby/lib/ruby/gems/2.3.0/gems/activesupport-5.1.2/
ib/active_support/dependencies.rb:292:in `require'", "C:/ActiveRuby/lib/ruby/gems/2.3.0/gems/activerecord-5.1.2/lib/act
ve_record/connection_adapters/connection_specification.rb:186:in `spec'", "C:/ActiveRuby/lib/ruby/gems/2.3.0/gems/activ
record-5.1.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:880:in `establish_connection'", "C:/Acti
eRuby/lib/ruby/gems/2.3.0/gems/activerecord-5.1.2/lib/active_record/connection_handling.rb:58:in `establish_connection'
, "C:/Users/franc/ActiveRubyTest/mysql_connect_test.rb:3:in `<top (required)>'", "C:/ActiveRuby/lib/ruby/gems/2.3.0/gem
/byebug-9.0.6/lib/byebug/runner.rb:174:in `debug_load'", "C:/ActiveRuby/lib/ruby/gems/2.3.0/gems/byebug-9.0.6/lib/byebu
/runner.rb:174:in `debug_program'", "C:/ActiveRuby/lib/ruby/gems/2.3.0/gems/byebug-9.0.6/lib/byebug/runner.rb:93:in `bl
ck in run'", "C:/ActiveRuby/lib/ruby/gems/2.3.0/gems/byebug-9.0.6/lib/byebug/runner.rb:92:in `loop'", "C:/ActiveRuby/li
/ruby/gems/2.3.0/gems/byebug-9.0.6/lib/byebug/runner.rb:92:in `run'", "C:/ActiveRuby/lib/ruby/gems/2.3.0/gems/byebug-9.
.6/bin/byebug:7:in `<top (required)>'", "C:/ActiveRuby/bin/byebug:22:in `load'", "C:/ActiveRuby/bin/byebug:22:in `<main
'"]

Apparently ruby has trouble loading libmysql.dll. Normally this file is included with the 'mysql2' gem. If I check with 'gem list', the gem does appear to be installed:

...
mysql2 (0.4.8)
...

However, there is no libmysql.dll file in the entire ActiveRuby folder :

C:\ActiveRuby>dir libmysql.dll /s
 Le volume dans le lecteur C n’a pas de nom.
 Le numéro de série du volume est 246A-791A
Fichier introuvable

Solving the issue

Manually reinstalling the 'mysql2' gem will add the missing libmysql.dll to ActiveRuby and solve this issue.

C:\ActiveRuby>gem install mysql2
Fetching: mysql2-0.4.8-x64-mingw32.gem (100%)

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

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

  At the time of building this gem, the necessary DLL files were retrieved from:
  http://cdn.mysql.com/Downloads/Connector-C/mysql-connector-c-6.1.10-win32.zip

  This gem *includes* vendor/libmysql.dll with redistribution notice in vendor/README.

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

Successfully installed mysql2-0.4.8-x64-mingw32
Parsing documentation for mysql2-0.4.8-x64-mingw32
Installing ri documentation for mysql2-0.4.8-x64-mingw32
Done installing documentation for mysql2 after 0 seconds
1 gem installed
C:\ActiveRuby>dir libmysql.dll /s
 Le volume dans le lecteur C n’a pas de nom.
 Le numéro de série du volume est 246A-791A

 Répertoire de C:\ActiveRuby\lib\ruby\gems\2.3.0\gems\mysql2-0.4.8-x64-mingw32\vendor

01/08/2017  00:14         4 879 360 libmysql.dll
               1 fichier(s)        4 879 360 octets

     Total des fichiers listés :
               1 fichier(s)        4 879 360 octets
               0 Rép(s)  169 107 656 704 octets libres

Repeatability

Completely uninstalling ActiveRuby and deleting the C:\ActiveRuby folder, and reinstalling ActiveRuby will reproduce the issue.