从本网站学习教程时出现此错误。
http://ruby.railstutorial.org/chapters/a-demo-app#sec-demo_users_resource
尝试在Windows上运行此rails命令
rails生成脚手架用户名:string email:string
并收到如下错误:
> .../lib/sqlite3.rb:6:in 'require':cannot load such file -- sqlite3/sqlite3_native(LoadError)
>../lib/sqlite3.rb:2:in rescue in <top(required) >
>../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 <main>
我已经尝试过其他答案,例如将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)在我的宝石列表中,但仍然出现此错误。 我也尝试将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提供此建议。
答案 0 :(得分:2)
见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 uninstall sqlite3
4. gem install sqlite3 --platform = ruby - --with-opt-dir = C:/ Knapsack / x86