【问题标题】:Cannot start a new rails server - sqlite.3h is missing无法启动新的 Rails 服务器 - sqlite.3h 丢失
【发布时间】:2013-04-26 12:45:18
【问题描述】:

我正在尝试在我的 Windows 7 操作系统上的 ruby​​ 上运行 rails 服务器。我创建了一个新的 rails 应用程序,但是当我尝试运行服务器时,出现以下错误:

D:\projects\RubyOnRails>rails server
=> Booting WEBrick
=> Rails 3.2.13 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
D:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/rubygems_integration.rb:214:in `block in replace_gem': Please
install the sqlite3 adapter: `gem install activerecord-sqlite3-adapter` (sqlite3 is not part of the  bundle. Add it to Gemfile.)

尝试安装activerecord-sqlite3-adapter:

D:\projects\RubyOnRails>gem install activerecord-sqlite3-adapter
ERROR:  Could not find a valid gem 'activerecord-sqlite3-adapter' (>= 0) in any repository
ERROR:  Possible alternatives: activerecord-jdbcsqlite3-adapter, activerecord-sqlserver-adapter, activerecord-bq-adapter, activerecord-simpledb-adapter, activerecord-mysql2-adapter

在我尝试安装 sqlite3 gem 后,我收到以下错误(我还必须安装 DevKit 才能继续执行此步骤):

D:\projects\RubyOnRails>gem install sqlite3
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing sqlite3:
ERROR: Failed to build gem native extension.

D:/Ruby200-x64/bin/ruby.exe extconf.rb
checking for sqlite3.h... no
sqlite3.h is missing. Install SQLite3 from http://www.sqlite.org/ first.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

System32 文件夹中,我有sqlite3.dllsqlite3.exesqlite 导出定义文件。

此外,sqlite3 似乎工作正常:

D:\projects\RubyOnRails>sqlite3
SQLite version 3.7.16.2 2013-04-12 11:52:43
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite>

另外,我的包是最新的:

D:\projects\RubyOnRails>bundle check
The Gemfile's dependencies are satisfied

但是在我的 gemfile 中没有关于 sqlite3 gem 版本的信息,当我放一个时,服务器无法启动:

source 'https://rubygems.org'

gem 'rails', '3.2.13'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'

请帮忙!

【问题讨论】:

  • 尝试 'gem update --system' 然后启动服务器
  • 类似于this question。看看吧。

标签: ruby-on-rails ruby sqlite


【解决方案1】:

你需要安装 sqlite3-ruby gem 而不是只安装 sqlite3

转到http://www.sqlite.org,并在“Precompiled Binaries For Windows”下下载 sqlitedll。解压文件,将两个文件 sqlite3.dll 和 sqlite3.def 放在 ruby​​ bin 的目录下,即 C:\ruby\bin。 运行“gem install sqlite3-ruby”来安装 sqlite3-ruby gem。 (如果最新版本不起作用,请尝试“gem install --version 1.2.3 sqlite3-ruby”)

【讨论】:

  • 你好,当我运行 gem install --version 1.2.3 sqlite3-ruby 时,我得到了同样的错误 - D:\projects\RubyOnRails>gem install --version 1.2.3 sqlite3-ruby Fetching: sqlite3-ruby-1.2.3.gem (100%) 暂时增强 PATH 以包含 DevKit... 构建原生扩展。这可能需要一段时间... 错误:安装 sqlite3-ruby 时出错:错误:无法构建 gem 原生扩展。 D:/Ruby200-x64/bin/ruby.exe extconf.rb 检查 fdatasync() 在 -lrt... 不检查 sqlite3.h... 没有 *** extconf.rb 失败 ***
  • 这可能会对您有所帮助。试试这个链接stackoverflow.com/questions/7371809/rails-sqlite-adapter-error
【解决方案2】:

问题是我使用的是 ruby​​ 2.x(目前是 beta 版,不能使用 sqlite3)而不是 1.9.3。

【讨论】:

    猜你喜欢
    • 2014-04-23
    • 2016-05-06
    • 2011-06-19
    • 1970-01-01
    相关资源
    最近更新 更多