【问题标题】:Rails generate command error?Rails生成命令错误?
【发布时间】:2014-06-23 19:48:20
【问题描述】:

我正在尝试在现有 Rails 网站上使用 Rails generate 命令来制作新控制器。

我将存储库签出到本地系统,但是当我尝试运行 generate 命令时,我收到以下错误:

C:/Ruby/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/mysql2.rb:
2:in `require': 126: The specified module could not be found.   - C:/Ruby/lib/ru
by/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/1.9/mysql2.so (LoadError
)
        from C:/Ruby/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysq
l2/mysql2.rb:2:in `<top (required)>'
        from C:/Ruby/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysq
l2.rb:9:in `require'
        from C:/Ruby/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysq
l2.rb:9:in `<top (required)>'
        from C:/Ruby/lib/ruby/gems/1.9.1/gems/bundler-1.6.3/lib/bundler/runtime.
rb:76:in `require'
        from C:/Ruby/lib/ruby/gems/1.9.1/gems/bundler-1.6.3/lib/bundler/runtime.
rb:76:in `block (2 levels) in require'
        from C:/Ruby/lib/ruby/gems/1.9.1/gems/bundler-1.6.3/lib/bundler/runtime.
rb:72:in `each'
        from C:/Ruby/lib/ruby/gems/1.9.1/gems/bundler-1.6.3/lib/bundler/runtime.
rb:72:in `block in require'
        from C:/Ruby/lib/ruby/gems/1.9.1/gems/bundler-1.6.3/lib/bundler/runtime.
rb:61:in `each'
        from C:/Ruby/lib/ruby/gems/1.9.1/gems/bundler-1.6.3/lib/bundler/runtime.
rb:61:in `require'
        from C:/Ruby/lib/ruby/gems/1.9.1/gems/bundler-1.6.3/lib/bundler.rb:132:i
n `require'
        from C:/Users/dboliver/Desktop/Assorted Items/RB_OLTARIS/branch/rails_3_
dev/config/application.rb:15:in `<top (required)>'
        from C:/Ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/commands
.rb:24:in `require'
        from C:/Ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/commands
.rb:24:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

【问题讨论】:

  • 你应该运行 bundle install 来安装缺失的 gem。
  • 即使在使用 bundle 后我仍然收到此错误
  • 好的,你应该使用bundle exec rails generate而不是rails generate来加载项目中的gem。
  • 仍然遇到同样的错误..

标签: ruby-on-rails ruby ruby-on-rails-3 ruby-1.9.3


【解决方案1】:

确保MySQL正在运行,就可以运行了

mysql.server start

确认命令

然后,运行

bundle install

验证是否也安装了 MySQL gem

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-15
    • 1970-01-01
    • 2021-12-04
    • 1970-01-01
    相关资源
    最近更新 更多