【发布时间】:2014-03-11 15:22:59
【问题描述】:
我在 Windows 7 上的 Ruby 2.0.0 上运行 Rails 4.0.3,并安装了 DevKit(所有 x64)。
我使用subst X: "C:\Program Files\MySQL\MySQL Server 5.6" 和gem install mysql2 --platform=ruby -- --with-mysql-dir=X: 安装了mysql2 gem,它安装得很好。然后我使用rails new mysql_testy 创建了一个运行良好的新应用程序,但是当我运行rails server 时出现以下错误:
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.15/lib/mysql2.rb:8:in 'require': 193: %1 is not a valid Win32 application. - C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.15/lib/mysql2/mysql2.so (LoadError)
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.15/lib/mysql2.rb:8:in '<top (required)>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:76:in 'require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:76:in 'block (2 levels) in require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:72:in 'each'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:72:in 'block in require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:61:in 'each'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:61:in 'require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler.rb:131:in 'require'
from C:/Users/Liam/Ruby/mysql_testy/config/application.rb:7:in '<top (required)>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.3/lib/rails/commands.rb:74:in 'require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.3/lib/rails/commands.rb:74:in 'block in <top (required)>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.3/lib/rails/commands.rb:71:in 'tap'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.3/lib/rails/commands.rb:71:in '<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'`
你们知道发生了什么吗?
【问题讨论】:
-
这个问题的答案应该可以解决你的问题:stackoverflow.com/questions/10468118/…
-
@rails4guides.com:在那个问题中,提问者安装了 mysql2 gem 的预编译二进制版本,而这里它是使用 DevKit 安装的,用于为我的系统构建本机扩展。此外,当我按照我在网上找到的指南尝试使用 Ruby 1.9.3 时(就像您链接到的问题的第一个答案),我什至没有正确安装 mysql2。
-
看来问题是Ruby是Win32,而你的MySql是Win64,导致出现不兼容错误。这篇文章或许能解决你的问题:blog.mmediasys.com/2011/07/07/…
-
你确定我的 Ruby 是 Win32 吗?我明确安装了 x64 版本的 Ruby...
标签: mysql ruby-on-rails ruby ruby-on-rails-4 webrick