1

Hi i got the same Problem like this guy: Ruby Guard questions - 'Please install the sqlite3 adapter' - railstutorial.org

Executing "bundle exec rspec spec/requests/static_pages_spec.rb" gives me this:

C:\Users\Me\Ruby\sample_app>bundle exec rspec spec/requests/static_pages_spec
.rb
Rack::File headers parameter replaces cache_control after Rack 1.5.
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/rubygems_integrati
on.rb:147:in `block in replace_gem': Please install the sqlite3 adapter: `gem in
stall activerecord-sqlite3-adapter` (sqlite3 is not part of the bundle. Add it t
o Gemfile.) (LoadError)
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_
record/connection_adapters/sqlite3_adapter.rb:3:in `<top (required)>'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active
_support/dependencies.rb:251:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active
_support/dependencies.rb:251:in `block in require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active
_support/dependencies.rb:236:in `load_dependency'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active
_support/dependencies.rb:251:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_
record/connection_adapters/abstract/connection_specification.rb:50:in `resolve_h
ash_connection'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_
record/connection_adapters/abstract/connection_specification.rb:41:in `resolve_s
tring_connection'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_
record/connection_adapters/abstract/connection_specification.rb:25:in `spec'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_
record/connection_adapters/abstract/connection_specification.rb:130:in `establis
h_connection'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_
record/railtie.rb:82:in `block (2 levels) in <class:Railtie>'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active
_support/lazy_load_hooks.rb:36:in `instance_eval'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active
_support/lazy_load_hooks.rb:36:in `execute_hook'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active
_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active
_support/lazy_load_hooks.rb:42:in `each'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active
_support/lazy_load_hooks.rb:42:in `run_load_hooks'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_
record/base.rb:720:in `<top (required)>'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-rails-2.11.0/lib/rspec/ra
ils/extensions/active_record/base.rb:19:in `<module:Extensions>'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-rails-2.11.0/lib/rspec/ra
ils/extensions/active_record/base.rb:4:in `<module:Rails>'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-rails-2.11.0/lib/rspec/ra
ils/extensions/active_record/base.rb:2:in `<module:RSpec>'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-rails-2.11.0/lib/rspec/ra
ils/extensions/active_record/base.rb:1:in `<top (required)>'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active
_support/dependencies.rb:251:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active
_support/dependencies.rb:251:in `block in require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active
_support/dependencies.rb:236:in `load_dependency'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active
_support/dependencies.rb:251:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-rails-2.11.0/lib/rspec/ra
ils/extensions.rb:1:in `<top (required)>'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active
_support/dependencies.rb:251:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active
_support/dependencies.rb:251:in `block in require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active
_support/dependencies.rb:236:in `load_dependency'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active
_support/dependencies.rb:251:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-rails-2.11.0/lib/rspec/ra
ils.rb:8:in `<top (required)>'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active
_support/dependencies.rb:251:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active
_support/dependencies.rb:251:in `block in require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active
_support/dependencies.rb:236:in `load_dependency'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active
_support/dependencies.rb:251:in `require'
        from C:/Users/Ayhan/Ruby/sample_app/spec/spec_helper.rb:4:in `<top (requ
ired)>'
        from C:/Users/Ayhan/Ruby/sample_app/spec/requests/static_pages_spec.rb:1
:in `require'
        from C:/Users/Ayhan/Ruby/sample_app/spec/requests/static_pages_spec.rb:1
:in `<top (required)>'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/cor
e/configuration.rb:780:in `load'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/cor
e/configuration.rb:780:in `block in load_spec_files'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/cor
e/configuration.rb:780:in `map'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/cor
e/configuration.rb:780:in `load_spec_files'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/cor
e/command_line.rb:22:in `run'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/cor
e/runner.rb:69:in `run'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/cor
e/runner.rb:8:in `block in autorun'

But my database.yml looks like this:

# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
development:
  adapter: postgresql
  host: localhost
  username: user
  database: app-dev

# 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

What do i have to change in here? Or is there another problem i cant see?

P.S: I installed postgreSQL, thats why i changed the development passage in the database.yml. And the gemfile looks like this:

source 'https://rubygems.org'

gem 'rails', '3.2.11'
gem 'pg', '0.12.2'

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

group :development, :test do
  gem 'rspec-rails', '2.11.0'
end

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

gem 'jquery-rails'

group :test do
  gem 'capybara', '1.1.2'
end

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the app server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'debugger'
Community
  • 1
  • 1
Acimaz
  • 171
  • 1
  • 14

1 Answers1

1

With the current configuration in config/database.yml, development env is on postgres while test & production are using sqlite3. And there is no sqlite3 gem included in the Gemfile. Hence the error message about Please install the sqlite3 adapter.

Why not use postgres for all of your environments instead of only for development?

Make the sections for test and production similar to that of development in config/database.yml with appropriate database names - database: app-test & database: app-prod` respectively.

Alternatively, if you want to use sqlite3 for certain environments, include the sqlite3 gem for that environment alone, and pg gem for the other environments.

Example Gemfile config:

The below config will include pg gem only for production, and sqlite3 gem only for development & test environment.

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

group :development, :test do
  gem 'sqlite3-ruby', :require => 'sqlite3'
end
Prakash Murthy
  • 12,923
  • 3
  • 46
  • 74
  • Ok i changed it but now its not executing at all, just saying this: Rack::File headers parameter replaces cache_control after Rack 1.5. I changed the database.yml like this: test: adapter: postgresql database: db/test pool: 5 timeout: 5000 username: user – Acimaz Feb 10 '13 at 16:33
  • Please change both `test` and `production` appropriately, and run `bundle install` before running the `bundle exec rspec spec/requests/static_pages_spec.rb` command. – Prakash Murthy Feb 10 '13 at 16:37
  • Since you are changing the database config for environments, you will also have to create the databases with `rake db:create`. – Prakash Murthy Feb 10 '13 at 16:45
  • What do you mean with changing them appropriately? The command doesnt start, i dont know why because there are no error messages now. I thought it would be easier to use postgreSQL for all environments. Changing the adapter name and the path to the database to db/development etc. didnt work :/ – Acimaz Feb 10 '13 at 16:45
  • Okay, the rake db:create command doesnt execute as well... had to abort with strg+c – Acimaz Feb 10 '13 at 16:46
  • Doing rake db:create --trace shows that it gets stuck at "** Execute db:create" .... rake db:migrate doesnt do anything as well – Acimaz Feb 10 '13 at 17:07
  • Creating a postgres database is a bit complicated for a beginner - as Michael Hartl too mentions in the book; I would suggest working with `sqlite` for the time being, and get back to Postgres later. http://railscasts.com/episodes/342-migrating-to-postgresql?view=asciicast would be helpful at that time. – Prakash Murthy Feb 11 '13 at 03:09
  • Yeah, i realized that and put the whole sqlite3 stuff back in. Now it works again – Acimaz Feb 11 '13 at 13:43