1

我正在尝试在我的 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

在我尝试安装sqlite3gem 后,我收到以下错误(我还必须安装 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.dll,sqlite3.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'

请帮忙!

4

2 回答 2

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”)

于 2013-05-02T12:12:23.297 回答
0

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

于 2013-06-27T22:43:56.573 回答