【问题标题】:cannot load such file sqlite3 - Rails Tutorial [duplicate]无法加载此类文件 sqlite3 - Rails 教程 [重复]
【发布时间】:2015-04-23 20:41:34
【问题描述】:

我正在关注 Rails 教程 https://www.railstutorial.org/book/toy_app,但在运行 $ rails generate scaffold User name:string email:string 时遇到错误

这是错误:

c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/sqlite3-1.3.9-x86-mingw32/l
ib/sqlite3.rb:6:in 'require': cannot load such file -- sqlite3/sqlite3_native (L
oadError)
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/sqlite3-1.3.9-
x86-mingw32/lib/sqlite3.rb:6:in 'rescue in <top (required)>'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/sqlite3-1.3.9-
x86-mingw32/lib/sqlite3.rb:2:in '<top (required)>'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:76:in 'require'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:76:in `block (2 levels) in require'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:72:in 'each'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:72:in 'block in require'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:61:in 'each'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:61:in 'require'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/
lib/bundler.rb:133:in 'require'
        from c:/sites/workspace/toy_app/config/application.rb:7:in '<top (requir
ed)>'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.2.0
/lib/rails/commands/commands_tasks.rb:141:in 'require'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.2.0
/lib/rails/commands/commands_tasks.rb:141:in 'require_application_and_environmen
t!'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.2.0
/lib/rails/commands/commands_tasks.rb:128:in 'generate_or_destroy'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.2.0
/lib/rails/commands/commands_tasks.rb:50:in 'generate'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.2.0
/lib/rails/commands/commands_tasks.rb:39:in 'run_command!'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.2.0
/lib/rails/commands.rb:17:in '<top (required)>'
        from bin/rails:4:in 'require'
        from bin/rails:4:in '<main>'

我使用的是 Windows 8。我使用的是 Gitbash。我从 install rails 网站安装了 ruby​​ 和 rails。当我输入 ruby​​ -v 我得到ruby 2.1.5p273 (2014-11-13 revision 48405) [i386-mingw32]

我尝试了here 提供的解决方案,但没有奏效。有什么想法吗?

【问题讨论】:

  • 你确定你的机器上安装了 sqlite?我不确定 Rails 是否会在您下载时自动安装它。
  • 当我输入sqlite --version 时,我得到sh.exe": sqlite: command not found。如何安装?
  • 再次检查您是否在 Gemfile 中的 group :development, :test 下添加了 gem 'gem 'sqlite3', '1.3.9'(并且您运行了 bundle install --without production)。
  • 是的,我运行了 bundle install --without production。我已经运行了 bundle install 并忘记了 --without 生产,但只是用它再次运行它。
  • 刚刚在 irb 中运行了这些命令,不确定是否有帮助:irb(main):001:0&gt; require 'sqlite3' =&gt; true irb(main):002:0&gt; SQLite3::SQLITE_VERSION =&gt; "3.8.7.1" irb(main):003:0&gt; exit

标签: ruby-on-rails ruby sqlite


【解决方案1】:

看起来this 帖子解决了我的问题。我需要使用包含对 Ruby 2.1 支持的 sqlite 1.3.10。 Sqlite 1.3.9 没有。

【讨论】:

    【解决方案2】:

    如果您使用 Windows 版 Rails Installer,它将安装您需要的所有内容。

    您可以从以下位置获取 Rails 安装程序:http://railsinstaller.org/en

    【讨论】:

    • 这是我用来安装所有东西的。我将卸载并重新安装,看看会发生什么。
    • 刚重装还是遇到同样的问题。
    • 看看这个解决方案:stackoverflow.com/questions/17643897/…
    • 当我进行更改时,我得到另一个错误这里是错误c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0/lib/act ive_support/dependencies.rb:274:in 'require': Could not load 'active_record/conn ection_adapters/sqlite3_adapter'. Make sure that the adapter in config/database. yml is valid. If you use an adapter other than 'mysql', 'mysql2', 'postgresql' o r 'sqlite3' add the necessary adapter gem to the Gemfile. (LoadError)的sn-p
    【解决方案3】:

    在您的项目终端上尝试:

    捆绑更新 sqlite3

    捆绑更新 nokogiri

    希望对你有所帮助;)

    【讨论】:

      猜你喜欢
      • 2014-04-23
      • 2018-10-19
      • 1970-01-01
      • 1970-01-01
      • 2013-07-12
      • 1970-01-01
      • 2018-08-19
      相关资源
      最近更新 更多