【发布时间】:2013-07-18 10:48:56
【问题描述】:
从本网站学习教程时出现此错误。
http://ruby.railstutorial.org/chapters/a-demo-app#sec-demo_users_resource
试图在 windows 上运行这个 rails 命令
rails 生成脚手架用户名:字符串电子邮件:字符串
并得到如下错误:
> .../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 ) 在我的 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 Distro。它会让生活变得美好对你来说容易多了。”切换到 Linux 解决了所有问题。感谢https://stackoverflow.com/users/1092260/althaf-hameez 的建议。
【问题讨论】:
-
你能粘贴你的database.yml(请隐藏任何敏感信息,如密码和IP地址)和你的Gemfile
-
@BenjaminSinclaire 我已将其添加到我的帖子中。请看一下并告诉我哪里出了问题。
-
同时添加您的 Gemfile。无论我看到你在 Windows 上学习如何偏离主题,你都会遇到一些纯粹因为在 Windows 上而令人沮丧的问题。如果您无法删除 Windows,请下载 Virtual Box 并在其上使用 Linux 发行版。它会让你的生活更轻松。
-
@AlthafHamez ..谢谢我也是这么想的..我不会将这个窗口用于任何未来的开发..这对我来说真的很令人沮丧..
-
按照建议,更好地使用 linux(如果您觉得使用它很舒服)而且对于您的问题,我只看到一个解决方案:在您的 Genfil 中验证您是否包含 sqlite gem
标签: ruby-on-rails ruby