Ruby-on-rails 错误“没有要加载的此类文件”——sqlite3/sqlite3_native (LoadError)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5800920/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 01:00:12  来源:igfitidea点击:

Error "no such file to load" -- sqlite3/sqlite3_native (LoadError)

ruby-on-railswindowssqlitefile-not-found

提问by Jorge Wander Santana Ure?a

My OS is Windows 7.

我的操作系统是 Windows 7。

My problem is that when I try to run rails server, an error occurs. I have installed the sqlite3gem, even the sqlite-rubygem, and still nothing.

我的问题是,当我尝试运行时rails server,会发生错误。我已经安装了sqlite3gem,甚至sqlite-rubygem,但仍然没有。

I already don't know what to do anymore.

我已经不知道该怎么办了。

If anyone needs any additional information, ask for it and I'll put it up.

如果有人需要任何其他信息,请索取,我会提供。

The complete error is:

完整的错误是:

C:/Ruby192/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.3-x86-mingw32/lib/sqlite3.rb:6:in `require': no such file to load -- sqlite3/sqlite3_native (LoadError)
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.3-x86-mingw32/lib/sqlite3.rb:6:in `rescue in <top (required)>'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.3-x86-mingw32/lib/sqlite3.rb:2:in `<top (required)>'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `each'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `block in require'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `each'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `require'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.12/lib/bundler.rb:120:in `require'
    from C:/Users/JorWan/Desktop/JorWan/ASCENDSTUDIO/RoR/intento2/config/application.rb:7:in `<top (required)>'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/commands.rb:28:in `require'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/commands.rb:28:in `block in <top (required)>'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/commands.rb:27:in `tap'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/commands.rb:27:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

采纳答案by HQM

download the required executable and the dll from http://www.sqlite.org/download.htmlextract to your ruby's bin (c:\Ruby192\bin)

将所需的可执行文件和 dll 从http://www.sqlite.org/download.html下载 到您的 ruby​​ 的 bin (c:\Ruby192\bin)

回答by Norman Se?ler

Forget all the so called "answers", no compiling of the sources or downloading pre-compiled libraries will solve this problem, believe me I tried everything, the problem lies somewhere else. This is how it works on windows:

忘记所有所谓的“答案”,没有编译源代码或下载预编译库可以解决这个问题,相信我,我尝试了一切,问题出在其他地方。这是它在 Windows 上的工作方式:

bundle update sqlite3

bundle update sqlite3

You likely get another similar error after this one regarding nokogiri, fix it with the command:

在这个关于 nokogiri 的错误之后,您可能会遇到另一个类似的错误,请使用以下命令修复它:

bundle update nokogiri

bundle update nokogiri

Enjoy your Ruby App!

享受您的 Ruby 应用程序!

回答by Kyle Sletten

Is that file (/sqlite3/sqlite3_native) in your PATHenvironment variable? It will need to be in order for that gem to work. If you need to check try using echo %PATH%on the command prompt. If it ends up that you need to add it to your path you can either SET PATH=%PATH%;C:\Path\To\Sqlite3or change your environment variables by selecting the Properties\Advances\Environment Variablesoption after right-clicking on My Computer. Edit the path variable to contain your path and viola!

该文件 ( /sqlite3/sqlite3_native) 是否在您的PATH环境变量中?需要它才能使该 gem 正常工作。如果您需要检查,请尝试echo %PATH%在命令提示符下使用。如果最终您需要将其添加到您的路径中,您可以SET PATH=%PATH%;C:\Path\To\Sqlite3通过Properties\Advances\Environment Variables在右键单击 后选择该选项或更改您的环境变量My Computer。编辑路径变量以包含您的路径和中提琴!

回答by Deepak Lamichhane

This URL provides the step-wise description and solution. Hope it works for you. http://rubyonwindowsguides.github.io/book/ch02-05.html

此 URL 提供了分步说明和解决方案。希望对你有效。 http://rubyonwindowsguides.github.io/book/ch02-05.html

回答by Saurabh Borse

If you have extracted "exe"s and "dll"s from Sqlite download linkto Ruby's bin folder and still have this problem. Try this:

如果您已经从Sqlite 下载链接中提取了“exe”和“dll”到 Ruby 的 bin 文件夹,但仍然存在此问题。尝试这个:

bundle update

bundle update

gem uninstall sqlite3

gem uninstall sqlite3

Given a choice between multiple versions of sqlite3, choose last option 'All versions'. Enter last number here

如果可以在多个版本的 sqlite3 之间进行选择,请选择最后一个选项“所有版本”。在此处输入最后一个数字

Select gem to uninstall:
1. sqlite3-1.3.13
2. sqlite3-1.3.13-x64-mingw32
3. All versions
>3.
.
If you remove this gem, these dependencies will not be met.
Continue with Uninstall? [yN]
> y

选择 gem 卸载:
1. sqlite3-1.3.13
2. sqlite3-1.3.13-x64-mingw32
3. 所有版本
> 3.
.
如果您删除此 gem,将不会满足这些依赖项。
继续卸载?[yN]
> y

gem install sqlite3 --platform=ruby

gem install sqlite3 --platform=ruby

rails server

rails server

This should work.

这应该有效。

Read through this linkfor more explanation if above works for you.

如果以上内容适合您,请通读此链接以获取更多解释。