rails生成rspec:install - 没有要加载的文件--sqlite3 / sqlite3_native(LoadError)

时间:2012-03-26 04:48:02

标签: ruby-on-rails-3 rspec

我正在尝试遵循此tutorial,当我尝试使用RSpec生成器时

$ rails generate rspec:install

我收到以下错误:

/usr/lib/ruby/gems/1.8/gems/sqlite3-1.3.5/lib/sqlite3.rb:6:in `require': no such file to load -- sqlite3/sqlite3_native (LoadError)
    from /usr/lib/ruby/gems/1.8/gems/sqlite3-1.3.5/lib/sqlite3.rb:6
    from /usr/lib/ruby/gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:68:in `require'
    from /usr/lib/ruby/gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:68:in `require'
    from /usr/lib/ruby/gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:in `each'
    from /usr/lib/ruby/gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:in `require'
    from /usr/lib/ruby/gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in `each'
    from /usr/lib/ruby/gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in `require'
    from /usr/lib/ruby/gems/1.8/gems/bundler-1.1.3/lib/bundler.rb:119:in `require'
    from /home/rcooke/sample_app/config/application.rb:13
    from /usr/lib/ruby/gems/1.8/gems/railties-3.2.2/lib/rails/commands.rb:24:in `require'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.2.2/lib/rails/commands.rb:24
    from script/rails:6:in `require'
    from script/rails:6

在对同一问题的其他讨论之后,我更改了我的Gemfile以包含以下内容:

group :development, :test do 
  gem 'sqlite3-ruby', :require => 'sqlite3'
  gem 'sqlite3', '1.3.5'
  gem 'rspec-rails'
  gem 'rspec'
end 

我注意到它们都已安装后,我在gemfile中添加了rspec和rspec-rails:

Using rspec-core (2.9.0)
Using rspec-expectations (2.9.0)
Using rspec-mocks (2.9.0)
Using rspec (2.9.0)
Using rspec-rails (2.9.0)

我甚至实施过:

$ gem install rspec

也许我没有使用正确的程序进行更新。在我的计算机上保存了Gemfile后,我正在使用捆绑更新捆绑安装。尝试 rails生成rspec:install 仍然失败。

更新:当我尝试运行资源时,我收到以下错误:

$ rake spec
rake aborted!
no such file to load -- sqlite3/sqlite3_native

更新:我显然搞砸了什么。现在,如果我尝试启动一个新的应用程序,我会收到以下错误。

$ rails new sample_app2 --skip-test-unit
/usr/lib/ruby/site_ruby/1.8/rubygems/dependency.rb:247:in `to_specs': Could not find json (~> 1.4) amongst [actionmailer-3.2.2, actionpack-3.2.2, activemodel-3.2.2, activerecord-3.2.2, activeresource-3.2.2, activesupport-3.2.2, addressable-2.2.7, arel-3.0.2, builder-3.0.0, bundler-1.1.3, bundler-1.1.2, coffee-rails-3.2.2, coffee-script-2.2.0, coffee-script-source-1.2.0, diff-lcs-1.1.3, erubis-2.7.0, execjs-1.3.0, heroku-2.22.0, heroku-2.21.3, hike-1.2.1, i18n-0.6.0, journey-1.0.3, jquery-rails-2.0.1, json_pure-1.6.6, launchy-2.1.0, mail-2.4.4, mime-types-1.18, multi_json-1.2.0, multi_json-1.1.0, netrc-0.7.1, polyglot-0.3.3, rack-1.4.1, rack-cache-1.2, rack-ssl-1.3.2, rack-test-0.6.1, rails-3.2.2, railties-3.2.2, rake-0.9.2.2, rdoc-3.12, rest-client-1.6.7, rspec-2.9.0, rspec-core-2.9.0, rspec-expectations-2.9.0, rspec-mocks-2.9.0, rspec-rails-2.9.0, rubyzip-0.9.6.1, sass-3.1.15, sass-rails-3.2.5, sprockets-2.3.1, sprockets-2.1.2, sqlite3-1.3.5, sqlite3-ruby-1.3.3, thor-0.14.6, tilt-1.3.3, treetop-1.4.10, tzinfo-0.3.32, uglifier-1.2.3] (Gem::LoadError)
    from /usr/lib/ruby/site_ruby/1.8/rubygems/specification.rb:772:in `activate_dependencies'
    from /usr/lib/ruby/site_ruby/1.8/rubygems/specification.rb:761:in `each'
    from /usr/lib/ruby/site_ruby/1.8/rubygems/specification.rb:761:in `activate_dependencies'
    from /usr/lib/ruby/site_ruby/1.8/rubygems/specification.rb:745:in `activate'
    from /usr/lib/ruby/site_ruby/1.8/rubygems/specification.rb:775:in `activate_dependencies'
    from /usr/lib/ruby/site_ruby/1.8/rubygems/specification.rb:761:in `each'
    from /usr/lib/ruby/site_ruby/1.8/rubygems/specification.rb:761:in `activate_dependencies'
    from /usr/lib/ruby/site_ruby/1.8/rubygems/specification.rb:745:in `activate'
    from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:1211:in `gem'
    from /usr/bin/rails:18

1 个答案:

答案 0 :(得分:0)

您的系统上是否安装了SQlite3库?当您查看 / usr / lib / 中的libsqlite3.so(假设您使用的是Linux)时,您会看到它吗?如果没有,那么你可以尝试安装它(通过apt-get / portage /你的软件包管理器),看看是否有帮助。