LoadError为数据库适配器指定'sqlite3'?

时间:2013-12-13 09:36:43

标签: ruby-on-rails ruby sqlite gem

My Gemfile如下所示:

source 'https://rubygems.org'

gem 'rails', '4.0.2'
gem 'bootstrap-sass', '2.1.0.0'
gem 'activesupport', '4.0.2'
gem 'jquery-rails', '2.0.2'
gem 'railties', '4.0.2'
gem 'sass-rails', '4.0.1'
gem 'coffee-rails', '4.0.1'
gem 'rails_12factor'
gem 'actionpack', '4.0.2'
gem 'sqlite3', '1.3.5'

group :development, :test do
  gem 'rspec-rails', '2.11.0'
  gem 'guard-rspec', '1.2.1'
  gem 'guard-spork', '1.2.0'
  gem 'childprocess', '0.3.6'
  gem 'spork', '0.9.2'
end

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails', '4.0.1'
  gem 'coffee-rails', '4.0.1'
  gem 'uglifier', '1.2.3'
end

group :test do
  gem 'capybara', '1.1.2'
  gem 'factory_girl_rails', '4.1.0'
  gem 'cucumber-rails', '1.2.1', :require => false
  gem 'database_cleaner', '0.7.0'
  # gem 'launchy', '2.1.0'
  # gem 'rb-fsevent', '0.9.1', :require => false
  # gem 'growl', '1.0.3'
end

group :production do
  gem 'pg', '0.12.2'
end

我运行bundle installbundle update但是当我在本地访问我的应用时出现此错误:

Specified 'sqlite3' for database adapter, but the gem is not loaded. 

Add gem 'sqlite3' to your Gemfile.

我尝试了bundle show sqlite3,我得到了/Users/siaW/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/sqlite3-1.3.5,这意味着我确实拥有了Gem吗?

那为什么不加载呢?

在我的database.yml我有这个:

# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
development:
  adapter: sqlite3
  database: db/development.sqlite3
  pool: 5
  timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: sqlite3
  database: db/test.sqlite3
  pool: 5
  timeout: 5000

production:
  adapter: sqlite3
  database: db/production.sqlite3
  pool: 5
  timeout: 5000

2 个答案:

答案 0 :(得分:0)

我想你可以试试这个:

  

进入你的Gemfile.lock文件并搜索'sqlite3'条目。你会注意到它读取sqlite3(1.3.8-x86-mingw32)。将其更改为sqlite3(1.3.8-x64-mingw32),然后运行bundle install命令,一切都应该正常工作。

来自Sqlite3 gem not loading, gem installed and specified in project

答案 1 :(得分:0)

我在OSX上为spec/dummy应用程序提供了此功能。在没有重建gemset(只是重建sqlite3)的情况下,它没有成功。

我必须执行以下操作才能正确构建所有内容:

rvm gemset empty
brew update
brew install sqlite
bundle update