【问题标题】:Error when starting the Rails server on Windows在 Windows 上启动 Rails 服务器时出错
【发布时间】:2016-08-03 22:56:29
【问题描述】:

在启动rails server 命令后,Ruby 终端没有启动服务器并写入以下内容:

C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/sqlite3-1.3.11-x64-mingw32/lib/sqlite3.rb:6:in `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)
    from C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/sqlite3-1.3.11-x64-mingw32/lib/sqlite3.rb:6:in `rescue in <top (required)>'
    from C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/sqlite3-1.3.11-x64-mingw32/lib/sqlite3.rb:2:in `<top (required)>'
    from C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:86:in `require'
    from C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:86:in `block (2 levels) in require'
    from C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:81:in `each'
    from C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:81:in `block in require'
    from C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:70:in `each'
    from C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:70:in `require'
    from C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler.rb:102:in `require'
    from C:/Sites/testing/config/application.rb:7:in `<top (required)>'
    from C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:88:in `require'
    from C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:88:in `block in server'
    from C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:85:in `tap'
    from C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:85:in `server'
    from C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
    from C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.0/lib/rails/commands.rb:18:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

在寻找类似问题的答案时,我没有找到任何可行的解决方案。我可以这么说:

  1. 应用创建在目录中,路径只有英文符号。
  2. 我尝试使用以下方法解决问题: gem cleanup bundle install
  3. 我尝试使用:bundle exec rails server 启动服务器。
  4. 我尝试删除 gemfile 中包含“问题”的 gem。
  5. 还尝试使用所有 gem 完全重新卸载 Ruby 和 Rails。

所有这些都没有帮助,所以我非常感谢您在我的案例解决方案中工作!

附:我正在开发:Windows 8.1(64 位)、Ruby 2.3.0、Rails 5.0.0

【问题讨论】:

标签: ruby-on-rails ruby windows server


【解决方案1】:

找到你的 sqlite3 gemspec 文件。一个例子是

`/usr/local/share`/gem/specifications/sqlite3-1.3.7.gemspec`

Windows:C:\Ruby21\lib\ruby\gems\2.1.0\specifications.

您应该根据您的 Rubygem 路径和 sqlite3 版本进行调整。编辑上面的文件并查找以下行

s.require_paths=["lib"]

改成

s.require_paths= ["lib/sqlite3_native"]

希望对你有帮助!!!

【讨论】:

  • 不幸的是,这也没有用。我尝试了您的解决方案,服务器正常启动,但其主页(例如 localhost:3000)显示如下:“无法加载 'active_record/connection_adapters/sqlite3_adapter'。请确保 config/database.yml 中的适配器有效。如果您使用 'mysql'、'mysql2'、'postgresql' 或 'sqlite3' 以外的适配器,将必要的适配器 gem 添加到 Gemfile。"
  • 确保您的 Gemfile 中有 gem 'sqlite3'。
猜你喜欢
  • 2012-06-29
  • 1970-01-01
  • 1970-01-01
  • 2012-04-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多