本文介绍了无法加载这样的文件 - mysql2 / 2.4 / mysql2(LoadError) - windows的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Ruby on Rails的新手。我的Ruby版本是ruby 2.4.1p111(2017-03-22修订版58053)[x64-mingw32]。



我使用 rails新sample_cms -d mysql 命令。

命令 rails server 会抛出以下错误。

  C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/mysql2-0.4.6-x64 -mingw32 / lib / mysql2 / mysql2.rb:2:in'require':无法加载这个文件 -  mysql2 / 2.4 / mysql2(LoadError)

我已经安装了mysql和mysql连接器C.我已经安装了mysql2这样的gem。

  gem install mysql2 -platform = ruby​​  - '-with-mysql-dir =C:\ Program Files \MySQL \ MySQL Connector C 6.1'

我已经卸载并安装了mysql2 gem,但仍然面临问题。
这是可能有问题的目录。





以下是mysql2的gem文件条目

 #Bundle edge改为导轨:gem'rails',github:'rails / rails'
gem'rails','〜> 5.1.1'
#使用mysql作为活动记录的数据库
gem'mysql2','> = 0.3.18','< 0.5'
#使用Puma作为应用服务器
gem'puma','〜> 3.7'

任何帮助?

解决方案

目前没有适用于Windows的Ruby 2.4的mysql2二进制文件。所以我卸载红宝石2.4并安装红宝石2.3。现在它工作的很好


I am new on Ruby on Rails. My Ruby version is ruby 2.4.1p111 (2017-03-22 revision 58053) [x64-mingw32].

I have created a new project using rails new sample_cms -d mysql command.

The command rails server is throwing following error.

C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/mysql2-0.4.6-x64-mingw32/lib/mysql2/mysql2.rb:2:in `require': cannot load such file -- mysql2/2.4/mysql2 (LoadError)

I have installed mysql and mysql Connector C. I have installed the mysql2 gem like that.

gem install mysql2 —platform=ruby — ‘—with-mysql-dir="C:\Program Files\MySQL\MySQL Connector C 6.1"’

I have uninstall and install the mysql2 gem but still facing the issue.Here is the directory which may have issue.

image of directory

Here is the gem file entry for mysql2

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.1'
# Use mysql as the database for Active Record
gem 'mysql2', '>= 0.3.18', '< 0.5'
# Use Puma as the app server
gem 'puma', '~> 3.7'

Any Help?

解决方案

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

这篇关于无法加载这样的文件 - mysql2 / 2.4 / mysql2(LoadError) - windows的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-03 22:39
查看更多