麻烦mysql2 gem与Windows 10和Rails 5兼容

时间:2017-08-28 14:18:57

标签: windows-10 ruby-on-rails-5 mysql2

OS: Windows 10
Rails 5.1.3
Ruby 2.4.1 (x64)

此外,我安装了msys并将其添加到路径中,它具有所需的所有工具。

我下载了mysql-connector-c-6.1.3-winx64.zip并将其解压缩到目录c:\ MySQLConnector

然后我做了:

gem uninstall mysql2

并卸载了所有mysql2版本

然后我做了:

cd c:\MySQLConnector\lib
rm libmysql.def
rm libmysql.lib
gendef.exe libmysql.dll
dlltool -v --dllname libmysql.dll --def libmysql.def --output-lib libmysql.lib
rm C:\Ruby24-x64\bin\libmysql.dll
rm C:\Ruby24-x64\bin\libmysql.lib
copy libmysql.dll C:\Ruby24-x64\bin
copy libmysql.lib C:\Ruby24-x64\bin
gem install mysql2 --platform=ruby -- '--with-mysql-dir="C:/MySQLConnector"'

完成时没有错误消息

这就是我在Gemfile中的内容:

gem 'mysql2', '>= 0.3.18', '< 0.5'

我删除了Gemfile.lock文件,然后:

bundle install

然后

rails s

我收到以下错误消息:

C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/mysql2-0.4.9-x64-mingw32/lib/mysql2/mysql2.rb:2:in `require': cannot load such file -- mysql2/2.4/mysql2 (LoadError)
    from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/mysql2-0.4.9-x64-mingw32/lib/mysql2/mysql2.rb:2:in `<top (required)>'
    from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/mysql2-0.4.9-x64-mingw32/lib/mysql2.rb:31:in `require'
    from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/mysql2-0.4.9-x64-mingw32/lib/mysql2.rb:31:in `<top (required)>'
    from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-1.15.4/lib/bundler/runtime.rb:82:in `require'
    from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-1.15.4/lib/bundler/runtime.rb:82:in `block (2 levels) in require'
    from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-1.15.4/lib/bundler/runtime.rb:77:in `each'
    from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-1.15.4/lib/bundler/runtime.rb:77:in `block in require'
    from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-1.15.4/lib/bundler/runtime.rb:66:in `each'
    from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-1.15.4/lib/bundler/runtime.rb:66:in `require'
    from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/bundler-1.15.4/lib/bundler.rb:108:in `require'
    from C:/myapp/config/application.rb:17:in `<top (required)>'
    from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.1.3/lib/rails/commands/server/server_command.rb:129:in `require'
    from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.1.3/lib/rails/commands/server/server_command.rb:129:in `block in perform'
    from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.1.3/lib/rails/commands/server/server_command.rb:126:in `tap'
    from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.1.3/lib/rails/commands/server/server_command.rb:126:in `perform'
    from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
    from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
    from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
    from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.1.3/lib/rails/command/base.rb:63:in `perform'
    from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.1.3/lib/rails/command.rb:44:in `invoke'
    from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.1.3/lib/rails/commands.rb:16:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'    

其他人使用Windows 10,使用Rails 5和Mysql2?

0 个答案:

没有答案