‘require’:无法加载这样的文件–sqlite3 / sqlite3_native(LoadError)

从本网站学习教程时出现此错误。

http://ruby.railstutorial.org/chapters/a-demo-app#sec-demo_users_resource

试图在Windows上运行此rails命令

rails generate scaffold用户名:string email:string

并得到如下错误:

> .../lib/sqlite3.rb:6:in 'require':cannot load such file -- sqlite3/sqlite3_native(LoadError) >../lib/sqlite3.rb:2:in rescue in  >../bundler/runtime.rb:72:in 'require' >.../bundler/runtime.rb:72:in block (2 level) >from bin/rails:4: in 'require' >from bin/rails:4: in  

我已经尝试过其他答案,例如将sqlite目录添加到PATH ..(它已经存在C:\ RailsInstaller \ Ruby2.0.0 \ lib \ ruby​​ \ gems \ 2.0.0 \ gems \ sqlite3-1.3.7-x86-mingw32) ..

sqlite3(1.3.7-x86-mingw32)在我的gem列表中,但仍然出现此错误。 我也尝试将sqlite3ext.h和sqlite3.h放入/ ext文件夹,但它无法正常工作

试过这个命令gem install sqlite3 –platform = ruby​​ – –with-sqlite3-dir = C:/ path / to / sqlite3没有结果

这里是我的database.yml的内容,这里是database.yml文件的内容

 # SQLite version 3.x # gem install sqlite3 # # Ensure the SQLite 3 gem is defined in your Gemfile # gem 'sqlite3' development: adapter: sqlite3 database: db/development.sqlite3 pool: 5 timeout: 5000 # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: adapter: sqlite3 database: db/test.sqlite3 pool: 5 timeout: 5000 production: adapter: sqlite3 database: db/production.sqlite3 pool: 5 timeout: 5000 

更新 :正如一个用户所建议的那样真正帮助我“你会遇到几个问题,这些问题纯粹是因为在Windows上会令人沮丧。如果你无法删除Windows,请下载Virtual Box并在其上使用Linux发行版。它将会让你的生活更轻松。“ 切换到Linux解决了一切。 感谢https://stackoverflow.com/users/1092260/althaf-hameez提供此建议。

请参阅https://stackoverflow.com/a/16748607/2466276 。

我的行动:
1.下载http://packages.openknapsack.org/sqlite/sqlite-3.7.15.2-x86-windows.tar.lzma
2.解压缩到C:\ Knapsack \ x86
3. gem卸载sqlite3
4. gem install sqlite3 –platform = ruby​​ – –with-opt-dir = C:/ Knapsack / x86