试图运行命令rails服务器(ruby on rails)

时间:2015-04-10 17:41:38

标签: ruby ruby-on-rails-4 mysql2

我试着开始使用rails。我已经制作了一个rails项目,现在我试图启动服务器但是得到了它。

C:\Users\Home\Documents\Sites\simple_cms>rails server
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mysql2-0.3.18-x64-mingw32/lib/mysql2/mysql2.rb:2:in `require': cannot load such file -- mysql2/2.2/mysql2 (LoadError)
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mysql2-0.3.18-x64-mingw32/lib/mysql2/mysql2.rb:2:in `<top (required)>'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mysql2-0.3.18-x64-mingw32/lib/mysql2.rb:31:in `require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mysql2-0.3.18-x64-mingw32/lib/mysql2.rb:31:in `<top (required)>'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.2/lib/bundler/runtime.rb:76:in `require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.2/lib/bundler/runtime.rb:72:in `each'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.2/lib/bundler/runtime.rb:72:in `block in require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.2/lib/bundler/runtime.rb:61:in `each'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.2/lib/bundler/runtime.rb:61:in `require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.9.2/lib/bundler.rb:134:in `require'
    from C:/Users/Home/Documents/Sites/simple_cms/config/application.rb:7:in `<top (required)>'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:78:in `require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:78:in `block in server'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:in `tap'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:in `server'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands.rb:17:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

我的gemfile有gem&#39; mysql2&#39;,&#39;〜&gt; 0.3.18&#39;

windows 7

ruby​​版本2.2.1

rails 4.2.1

mySql服务器版本5.6.24

编辑: 无法找到适合我的解决方案,所以我安装了不同版本的rails并且它已经解决了。

3 个答案:

答案 0 :(得分:0)

确保您使用mysql2安装了bundle install gem并且bundle install已成功安装。

答案 1 :(得分:0)

答案 2 :(得分:0)

尝试更改

gem 'mysql2', '~> 0.3.18'

gem 'mysql2', '~> 0.3.11'

我认为与Windows的最大兼容版本是0.3.11。然后再次运行bundle install