在 Windows 上启动 Rails 服务器时出错 [英] Error when starting the Rails server on Windows
问题描述
在启动 rails server
命令后,Ruby 终端没有启动服务器并写入以下内容:
Right after launching rails server
command Ruby terminal doesn't start the server and writes following:
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>'
在寻找类似问题的答案时,我没有找到任何可行的解决方案.我可以这么说:
When looking for answers to similar question, I haven't found any working solution. I can say that:
- 应用程序创建在目录中,其中路径只有英文符号.
- 我尝试使用以下方法解决问题:
宝石清理捆绑安装
- 我尝试使用以下命令启动服务器:
bundle exec rails server
. - 我试图删除 gemfile 中包含问题"的 gem.
- 还尝试使用所有 gem 完全重新安装 Ruby 和 Rails.
所有这些都无济于事,因此我非常感谢您在我的案例解决方案中工作!
All that didn't help, so I would really appreciate for working in my case solution!
附言我正在开发:Windows 8.1(64 位)、Ruby 2.3.0、Rails 5.0.0
P.S. I am working on: Windows 8.1 (64-bit), Ruby 2.3.0, Rails 5.0.0
推荐答案
找到您的 sqlite3 gemspec 文件.一个例子是
Find your sqlite3 gemspec file. One example is
`/usr/local/share`/gem/specifications/sqlite3-1.3.7.gemspec`
Windows:C:\Ruby21\lib\ruby\gems\2.1.0\specifications.
您应该根据您的 Rubygem 路径和 sqlite3 版本进行调整.编辑上面的文件并查找以下行
You should adjust according with your Rubygem path and sqlite3 version. Edit the file above and look for the following line
s.require_paths=["lib"]
改成
s.require_paths= ["lib/sqlite3_native"]
希望有帮助!!!
这篇关于在 Windows 上启动 Rails 服务器时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!