【问题标题】:Ruby on Rails - Couln't find mysql2.soRuby on Rails - 找不到 mysql2.so
【发布时间】:2014-10-12 01:28:32
【问题描述】:

我已经在 Ruby on Rails 上工作 2 个月了,现在我想更改数据库系统,所以我通过以下命令安装了 gem mysql2:

gem install mysql2 --platform=ruby -- '--with-mysql-lib="C:\mysql-connector\lib" --with-mysql-include="C:\mysql-connector\include" --with-mysql-dir="C:\mysql-connector"'

而且它有效!

但问题是当我想再次运行 rails server 时出现此错误

c:\zreactor\demo>rails server
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.16/lib/mysql2.rb:8:in `requir
e': 126: The specified module could not be found.   - C:/Ruby200-x64/lib/ruby/ge
ms/2.0.0/extensions/x64-mingw32/2.0.0/mysql2-0.3.16/mysql2/mysql2.so (LoadError)

        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.16/lib/mysql2.rb
:8:in `<top (required)>'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.7.3/lib/bundler/r
untime.rb:76:in `require'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.7.3/lib/bundler/r
untime.rb:76:in `block (2 levels) in require'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.7.3/lib/bundler/r
untime.rb:72:in `each'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.7.3/lib/bundler/r
untime.rb:72:in `block in require'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.7.3/lib/bundler/r
untime.rb:61:in `each'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.7.3/lib/bundler/r
untime.rb:61:in `require'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.7.3/lib/bundler.r
b:133:in `require'
        from c:/zreactor/demo/config/application.rb:7:in `<top (required)>'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/co
mmands.rb:74:in `require'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/co
mmands.rb:74:in `block in <top (required)>'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/co
mmands.rb:71:in `tap'
        from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/co
mmands.rb:71:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'

我搜索了源代码,看起来一切正常,但我不知道为什么会出现此错误。

我正在使用 ruby​​ 2.0 和 rails 4.0.2 开发 W8。

感谢您的帮助, 谢谢!

【问题讨论】:

  • 欢迎来到 SO!写得很好的问题。指定的文件(C:/Ruby200-x64/lib/ruby/gems/2.0.0/extensions/x64-mingw32/2.0.0/mysql2-0.3.16/mysql2/mysql2.so)真的存在吗?
  • 谢谢贾里德。该文件存在,我正在使用 x64 mysql 连接器库。
  • 你见过github.com/brianmario/mysql2/issues/359吗?这似乎是相关的,也许吧?抱歉,我帮不上忙。
  • 感谢 Jared,我找到了正确的连接器!我也没有复制属于我的问题的库文件。谢谢!

标签: mysql ruby-on-rails ruby mysql2


【解决方案1】:

您很可能需要重新生成libmysql.lib,如下所述:

...mysql2/mysql2.so: [BUG] Segmentation fault ruby 2.0.0p247

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-11
    • 2011-09-18
    • 2020-10-12
    • 1970-01-01
    • 1970-01-01
    • 2022-07-13
    相关资源
    最近更新 更多