简体   繁体   English

无法加载此类文件-mysql2 / 2.4 / mysql2(LoadError)-Windows

[英]cannot load such file — mysql2/2.4/mysql2 (LoadError) - windows

I am new on Ruby on Rails. 我是Ruby on Rails的新手。 My Ruby version is ruby 2.4.1p111 (2017-03-22 revision 58053) [x64-mingw32]. 我的Ruby版本是ruby 2.4.1p111(2017-03-22修订版58053)[x64-mingw32]。

I have created a new project using rails new sample_cms -d mysql command. 我使用rails new sample_cms -d mysql命令创建了一个新项目。

The command rails server is throwing following error. 命令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': 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. 我已经安装了mysql和mysql ConnectorC。我已经安装了mysql2 gem。

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. 我已经卸载并安装了mysql2 gem,但仍然面临问题。 Here is the directory which may have issue. 这是可能有问题的目录。

image of directory 目录图片

Here is the gem file entry for mysql2 这是mysql2的gem文件条目

# 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. 目前没有适用于Windows的Ruby 2.4的mysql2二进制文件。 So i uninstall ruby 2.4 and install ruby 2.3. 所以我卸载了ruby 2.4并安装了ruby 2.3。 Now it is working well 现在运作良好

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM