【问题标题】:LoadError Specified 'sqlite3' for database adapter?LoadError 为数据库适配器指定'sqlite3'?
【发布时间】:2014-01-01 00:37:31
【问题描述】:

我的 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,这意味着我确实拥有宝石,对吗?

那么为什么不加载呢?

在我的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

【问题讨论】:

  • 尝试将其从开发组中删除。
  • 你在哪里部署?你的服务器支持 sqlite 吗?
  • @papirtiger 本地...
  • 抱歉,没有正确阅读。你试过gem pristine sqlite3吗?
  • 是的,我试过了。没有。还是一样的错误。

标签: ruby-on-rails ruby sqlite gem


【解决方案1】:

我想你可以试试这个:

进入您的 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

【讨论】:

    【解决方案2】:

    我在 OSX 上为 spec/dummy 应用程序安装了这个。没有重建 gemset(只是重建 sqlite3),它是不成功的。

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

    rvm gemset empty
    brew update
    brew install sqlite
    bundle update
    

    【讨论】:

    • 请不要对多个问题发布相同的答案。相反,将问题标记为重复,并将一个 good 答案发布到问题的 一个 副本。
    猜你喜欢
    • 2014-08-11
    • 1970-01-01
    • 2023-03-17
    • 1970-01-01
    • 1970-01-01
    • 2015-01-13
    • 2017-10-18
    • 2015-12-04
    • 1970-01-01
    相关资源
    最近更新 更多