I have ran mysql2 install (3.11) successfully and activerecord-mysql2-adapter is in my gem list. I have run bundle install when I did created new project.
C:/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 mysql2 adapter: 'gem install activerecord-mysql2-adapter' (mysql2 is not part of the bundle. Add it to Gemfile.) (LoadError)
Please help me, I cant even get rails server running. Could my other programs be blocking rails or possibly fire wall? What program can I allow in firewall if so?
My Gemfile specifies the following.
source 'https://rubygems.org'
gem 'rails'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# 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'
My Error generated is here
Exiting
C:/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 mysql2 adapter: `gem install activerecord-mysql2-adapter` (mysql2 is not part of the bundle. Add it to Gemfile.) (LoadError)
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/mysql2_adapter.rb:3:in `<top (required)>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:50:in `resolve_hash_connection'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:41:in `resolve_string_connection'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:25:in `spec'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:130:in `establish_connection'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-3.2.13/lib/active_record/railtie.rb:82:in `block (2 levels) in <class:Railtie>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:42:in `each'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-3.2.13/lib/active_record/base.rb:720:in `<top (required)>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-3.2.13/lib/active_record/railtie.rb:88:in `block in <class:Railtie>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/i
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
from C:/Users/Charlie/Documents/RailsProject/shop/config/environment.rb:5:in `<top (required)>'
from C:/Users/Charlie/Documents/RailsProject/shop/config.ru:3:in `require'
from C:/Users/Charlie/Documents/RailsProject/shop/config.ru:3:in `block in <main>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack1.4.5/lib/rack/builder.rb:51:in`instance_eval'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:51:in`initialize'
from C:/Users/Charlie/Documents/RailsProject/shop/config.ru:in `new'
from C:/Users/Charlie/Documents/RailsProject/shop/config.ru:in `<main>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:40:in`parse_file'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.4.5/lib/rack/server.rb:200:in `app'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties3.2.13/lib/rails/commands/server.rb:46:in `app'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.4.5/lib/rack/server.rb:304:in`wrapped_app'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.4.5/lib/rack/server.rb:254:in `start'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties3.2.13/lib/rails/commands/server.rb:70:in `start' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/commands.rb:55:in `block in <top (required)>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/commands.rb:50:in `tap'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
You have to make sure that your database.yml file is correct.
You should have
adapter: mysql2 not mysql/anything
Thanks.
plz check your config/database.yml file in it your structure should be like this
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: abc_development
pool: 5
username: your_database_username
password: your_database_password
host: localhost
for all 3 environments
and most important you should create your mysql databse for this you have mysql install on your system.give username and password to your database and add it in your database.yml file
Related
I uses Rails but it does not follow the settings in config/database.yml.
With config/database.yml ($DATABASE_URL is the URL of my Heroku app's database)
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
adapter: sqlite3
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
# 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:
<<: *default
database: db/test.sqlite3
production:
<<: *default
url: <%= ENV['DATABASE_URL'] %>
I ran rails g controller hoge, then I got errors:
/myapp/vendor/bundle/ruby/2.5.0/gems/activerecord-5.1.6/lib/active_record/connection_adapters/connection_specification.rb:188:in `rescue in spec': Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord). (Gem::LoadError)
from /myapp/vendor/bundle/ruby/2.5.0/gems/activerecord-5.1.6/lib/active_record/connection_adapters/connection_specification.rb:185:in `spec'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activerecord-5.1.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:880:in `establish_connection'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activerecord-5.1.6/lib/active_record/connection_handling.rb:58:in `establish_connection'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activerecord-5.1.6/lib/active_record/railtie.rb:124:in `block (2 levels) in <class:Railtie>'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/lazy_load_hooks.rb:69:in `instance_eval'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/lazy_load_hooks.rb:60:in `with_execution_control'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/lazy_load_hooks.rb:65:in `execute_hook'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/lazy_load_hooks.rb:50:in `block in run_load_hooks'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/lazy_load_hooks.rb:49:in `each'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/lazy_load_hooks.rb:49:in `run_load_hooks'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activerecord-5.1.6/lib/active_record/base.rb:326:in `<module:ActiveRecord>'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activerecord-5.1.6/lib/active_record/base.rb:25:in `<top (required)>'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `block in require'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:256:in `block in load_dependency'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:662:in `new_constants_in'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:256:in `load_dependency'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
from /myapp/app/models/application_record.rb:1:in `<top (required)>'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:477:in `load'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:477:in `block in load_file'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:662:in `new_constants_in'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:476:in `load_file'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:374:in `block in require_or_load'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:36:in `block in load_interlock'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies/interlock.rb:12:in `block in loading'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/concurrency/share_lock.rb:149:in `exclusive'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies/interlock.rb:11:in `loading'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:36:in `load_interlock'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:357:in `require_or_load'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:511:in `load_missing_constant'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:202:in `const_missing'
from /myapp/app/models/user.rb:1:in `<top (required)>'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:477:in `load'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:477:in `block in load_file'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:662:in `new_constants_in'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:476:in `load_file'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:374:in `block in require_or_load'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:36:in `block in load_interlock'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies/interlock.rb:12:in `block in loading'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/concurrency/share_lock.rb:149:in `exclusive'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies/interlock.rb:11:in `loading'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:36:in `load_interlock'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:357:in `require_or_load'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:511:in `load_missing_constant'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:202:in `const_missing'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/inflector/methods.rb:269:in `const_get'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/inflector/methods.rb:269:in `block in constantize'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/inflector/methods.rb:267:in `each'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/inflector/methods.rb:267:in `inject'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/inflector/methods.rb:267:in `constantize'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:583:in `get'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:614:in `constantize'
from /myapp/vendor/bundle/ruby/2.5.0/gems/devise-4.4.3/lib/devise.rb:316:in `get'
from /myapp/vendor/bundle/ruby/2.5.0/gems/devise-4.4.3/lib/devise/mapping.rb:83:in `to'
from /myapp/vendor/bundle/ruby/2.5.0/gems/devise-4.4.3/lib/devise/mapping.rb:78:in `modules'
from /myapp/vendor/bundle/ruby/2.5.0/gems/devise-4.4.3/lib/devise/mapping.rb:95:in `routes'
from /myapp/vendor/bundle/ruby/2.5.0/gems/devise-4.4.3/lib/devise/mapping.rb:162:in `default_used_route'
from /myapp/vendor/bundle/ruby/2.5.0/gems/devise-4.4.3/lib/devise/mapping.rb:72:in `initialize'
from /myapp/vendor/bundle/ruby/2.5.0/gems/devise-4.4.3/lib/devise.rb:346:in `new'
from /myapp/vendor/bundle/ruby/2.5.0/gems/devise-4.4.3/lib/devise.rb:346:in `add_mapping'
from /myapp/vendor/bundle/ruby/2.5.0/gems/devise-4.4.3/lib/devise/rails/routes.rb:243:in `block in devise_for'
from /myapp/vendor/bundle/ruby/2.5.0/gems/devise-4.4.3/lib/devise/rails/routes.rb:242:in `each'
from /myapp/vendor/bundle/ruby/2.5.0/gems/devise-4.4.3/lib/devise/rails/routes.rb:242:in `devise_for'
from /myapp/config/routes.rb:2:in `block in <top (required)>'
from /myapp/vendor/bundle/ruby/2.5.0/gems/actionpack-5.1.6/lib/action_dispatch/routing/route_set.rb:436:in `instance_exec'
from /myapp/vendor/bundle/ruby/2.5.0/gems/actionpack-5.1.6/lib/action_dispatch/routing/route_set.rb:436:in `eval_block'
from /myapp/vendor/bundle/ruby/2.5.0/gems/actionpack-5.1.6/lib/action_dispatch/routing/route_set.rb:418:in `draw'
from /myapp/config/routes.rb:1:in `<top (required)>'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:286:in `load'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:286:in `block in load'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:258:in `load_dependency'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:286:in `load'
from /myapp/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/application/routes_reloader.rb:55:in `block in load_paths'
from /myapp/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/application/routes_reloader.rb:55:in `each'
from /myapp/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/application/routes_reloader.rb:55:in `load_paths'
from /myapp/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/application/routes_reloader.rb:18:in `reload!'
from /myapp/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/application/routes_reloader.rb:41:in `block in updater'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/file_update_checker.rb:81:in `execute'
from /myapp/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/application/routes_reloader.rb:42:in `updater'
from /myapp/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/application/routes_reloader.rb:31:in `execute_if_updated'
from /myapp/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/application/finisher.rb:128:in `block in <module:Finisher>'
from /myapp/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/initializable.rb:30:in `instance_exec'
from /myapp/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/initializable.rb:30:in `run'
from /myapp/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/initializable.rb:59:in `block in run_initializers'
from /home/.rbenv/versions/2.5.0/lib/ruby/2.5.0/tsort.rb:228:in `block in tsort_each'
from /home/.rbenv/versions/2.5.0/lib/ruby/2.5.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
from /home/.rbenv/versions/2.5.0/lib/ruby/2.5.0/tsort.rb:431:in `each_strongly_connected_component_from'
from /home/.rbenv/versions/2.5.0/lib/ruby/2.5.0/tsort.rb:349:in `block in each_strongly_connected_component'
from /home/.rbenv/versions/2.5.0/lib/ruby/2.5.0/tsort.rb:347:in `each'
from /home/.rbenv/versions/2.5.0/lib/ruby/2.5.0/tsort.rb:347:in `call'
from /home/.rbenv/versions/2.5.0/lib/ruby/2.5.0/tsort.rb:347:in `each_strongly_connected_component'
from /home/.rbenv/versions/2.5.0/lib/ruby/2.5.0/tsort.rb:226:in `tsort_each'
from /home/.rbenv/versions/2.5.0/lib/ruby/2.5.0/tsort.rb:205:in `tsort_each'
from /myapp/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/initializable.rb:58:in `run_initializers'
from /myapp/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/application.rb:353:in `initialize!'
from /myapp/config/environment.rb:5:in `<top (required)>'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `block in require'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:258:in `load_dependency'
from /myapp/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
from /myapp/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:102:in `preload'
from /myapp/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:153:in `serve'
from /myapp/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:141:in `block in run'
from /myapp/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:135:in `loop'
from /myapp/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:135:in `run'
from /myapp/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/lib/spring/application/boot.rb:19:in `<top (required)>'
from /home/.rbenv/versions/2.5.0/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
from /home/.rbenv/versions/2.5.0/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
from -e:1:in `<main>'
In Gemfile:
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.4'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '~> 2.13'
gem 'selenium-webdriver'
gem 'pry-rails'
gem 'pry-doc'
gem 'pry-byebug'
gem 'pry-stack_explorer'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
gem 'letter_opener'
gem 'letter_opener_web'
end
group :production do
gem 'pg', '~> 0.20'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'config'
gem 'bootstrap-sass'
gem 'kaminari'
gem 'jquery-rails'
gem 'gon'
gem 'faraday'
gem 'faraday_middleware'
gem 'devise'
gem 'devise-bootstrap-views'
gem 'data-confirm-modal'
My ruby version is v2.5.0 and OS is macOS Sierra 10.12.6.
Why the adapter is set to postgresql in spite of sqlite3 in config/database.yml?
How can I use the configurations correctly?
I think of migrating developing environment to virtual box (to avoid cumbersome problems like this), but I am afraid that, in the box, I would get such errors as well. Is it OK?
Rails is using the connection details from the environment variable, not the config file. Rails uses both ENV['DATABASE_URL'] and config/database.yml when setting up the database, and in most cases the environment variable has priority.
Take a look at the docs to see how the two ways of configuring the database interact.
The simplest solution in your case is probably to remove the DATABASE_URL varaible from your development machine. It’s unlikely you need it set there, and could possibly cause problems if you accidentally connect to the production database from development.
You could also use the url: key rather than the database: key when specifying the development database, as that key does take precedence over the environment variable. It would look something like:
development:
<<: *default
url: sqlite:db/development.sqlite3
You should also probably remove the adapter from defaults, as you are not using sqlite in production but are merging in that key. What you have will likely work (since the environment variable overrides the setting in the file), but it is confusing. Ideally you would want to look into using the same database in development and production to minimise differences between the two environments.
This question already has an answer here:
Rails application using Postgres adapter can't activate pg
(1 answer)
Closed 5 years ago.
I've been doing the Rails tutorial found here and have been successful up to the point of having to migrate the Comments migration using $ rails db:migrate. Prior to this point, I've been able to generate the Article model and migrate the Articles create migration with no issues. In between these two migrations, nothing has changed in my Gemfile, so I'm not sure what it is Bundler is having an issue with.
Here are the errors, followed by the full command-line output, along with my Gemfile and schema.rb:
Gem::LoadError: can't activate pg (~> 0.18), already activated pg-1.0.0.
Gem::LoadError: Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).
Full command-line output
xxx:gangelo: ~/dev/rails/test/blog (master*) ☠ rbenv exec rails db:migrate
rails aborted!
Gem::LoadError: Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/connection_specification.rb:188:in `rescue in spec'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/connection_specification.rb:185:in `spec'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:880:in `establish_connection'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/connection_handling.rb:58:in `establish_connection'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/railtie.rb:124:in `block (2 levels) in <class:Railtie>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:69:in `instance_eval'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:60:in `with_execution_control'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:65:in `execute_hook'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:50:in `block in run_load_hooks'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:49:in `each'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:49:in `run_load_hooks'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/base.rb:326:in `<module:ActiveRecord>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/base.rb:25:in `<top (required)>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `block in require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/mysql_database_tasks.rb:6:in `<class:MySQLDatabaseTasks>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/mysql_database_tasks.rb:3:in `<module:Tasks>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/mysql_database_tasks.rb:2:in `<module:ActiveRecord>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/mysql_database_tasks.rb:1:in `<top (required)>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `block in require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:74:in `<module:DatabaseTasks>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:35:in `<module:Tasks>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:2:in `<module:ActiveRecord>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:1:in `<top (required)>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `block in require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/railtie.rb:34:in `block (3 levels) in <class:Railtie>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/railties-5.1.4/lib/rails/commands/rake/rake_command.rb:21:in `block in perform'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/railties-5.1.4/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/railties-5.1.4/lib/rails/command.rb:46:in `invoke'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/railties-5.1.4/lib/rails/commands.rb:16:in `<top (required)>'
/Users/gangelo/dev/rails/test/blog/bin/rails:9:in `require'
/Users/gangelo/dev/rails/test/blog/bin/rails:9:in `<top (required)>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
/Users/gangelo/dev/rails/test/blog/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Caused by:
Gem::LoadError: can't activate pg (~> 0.18), already activated pg-1.0.0. Make sure all dependencies are added to Gemfile.
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:2:in `<top (required)>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `block in require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/connection_specification.rb:186:in `spec'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:880:in `establish_connection'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/connection_handling.rb:58:in `establish_connection'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/railtie.rb:124:in `block (2 levels) in <class:Railtie>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:69:in `instance_eval'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:60:in `with_execution_control'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:65:in `execute_hook'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:50:in `block in run_load_hooks'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:49:in `each'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:49:in `run_load_hooks'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/base.rb:326:in `<module:ActiveRecord>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/base.rb:25:in `<top (required)>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `block in require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/mysql_database_tasks.rb:6:in `<class:MySQLDatabaseTasks>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/mysql_database_tasks.rb:3:in `<module:Tasks>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/mysql_database_tasks.rb:2:in `<module:ActiveRecord>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/mysql_database_tasks.rb:1:in `<top (required)>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `block in require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:74:in `<module:DatabaseTasks>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:35:in `<module:Tasks>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:2:in `<module:ActiveRecord>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:1:in `<top (required)>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `block in require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/activerecord-5.1.4/lib/active_record/railtie.rb:34:in `block (3 levels) in <class:Railtie>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/railties-5.1.4/lib/rails/commands/rake/rake_command.rb:21:in `block in perform'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/railties-5.1.4/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/railties-5.1.4/lib/rails/command.rb:46:in `invoke'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/railties-5.1.4/lib/rails/commands.rb:16:in `<top (required)>'
/Users/gangelo/dev/rails/test/blog/bin/rails:9:in `require'
/Users/gangelo/dev/rails/test/blog/bin/rails:9:in `<top (required)>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
/Users/gangelo/dev/rails/test/blog/vendor/bundle/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
/Users/gangelo/dev/rails/test/blog/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Tasks: TOP => db:migrate => db:load_config
(See full trace by running task with --trace)
Gemfile
source 'https://rubygems.org'
ruby '2.3.1'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.4'
# Use sqlite3 as the database for Active Record
# gem 'sqlite3'
# Use postgres as the database for Active Record
gem 'pg'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '~> 2.13'
gem 'selenium-webdriver'
end
# gma - start
group :development, :test do
gem 'rspec-rails', '~> 3.5', '>= 3.5.2'
gem 'rspec-activemodel-mocks', '~> 1.0', '>= 1.0.3'
gem 'shoulda-matchers', '~> 3.1', '>= 3.1.1'
gem 'factory_bot_rails', '~> 4.8', '>= 4.8.2'
gem 'ffaker', '~> 2.2'
# gem 'timecop', '~> 0.8.1'
end
# gma - end
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
Schema.rb
ActiveRecord::Schema.define(version: 20180110153949) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
create_table "articles", force: :cascade do |t|
t.string "title"
t.text "text"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
end
Migration file
class CreateComments < ActiveRecord::Migration[5.1]
def change
create_table :comments do |t|
t.string :commenter
t.text :body
t.references :article, foreign_key: true
t.timestamps
end
end
end
looks like pg 1.0 is not compatible with rails 5.1.4 at the moment.
gem 'pg', '~> 0.18'
0.18 worked for me.
Turns out the postgres gem version 1.0.0 is not compatible with Rails 5.1.4. When I changed the postgres gem version to '~> 0.18', everything worked fine:
Changed from:
gem 'pg' # Defaults to latest version 1.0.0 (not compatible with Rails 5.1.4).
Changed to:
gem 'pg', '~> 0.18'
I have a rails app that's working totally fine locally but when i pushed it on heroku it showing "Application Error"enter image description here
i tried visiting the heroku app logs but there was nothing out there, but when i tried running heroko console it started giving this error:
C:\Sites\bbb>heroku run rails console
This is the legacy Heroku CLI. Please install the new CLI from https://cli.herok
u.com
Running rails console on hidden-hollows-63773... up, run.4100 (Free)
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connecti
on_adapters/connection_specification.rb:176:in `rescue in spec': Specified 'sqli
te3' for database adapter, but the gem is not loaded. Add `gem 'sqlite3'` to you
r Gemfile (and ensure its version is at the minimum required by ActiveRecord). (
Gem::LoadError)
from /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_re
cord/connection_adapters/connection_specification.rb:173:in `spec'
from /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_re
cord/connection_handling.rb:53:in `establish_connection'
from /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_re
cord/railtie.rb:125:in `block (2 levels) in <class:Railtie>'
from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s
upport/lazy_load_hooks.rb:43:in `instance_eval'
from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s
upport/lazy_load_hooks.rb:43:in `execute_hook'
from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s
upport/lazy_load_hooks.rb:50:in `block in run_load_hooks'
from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s
upport/lazy_load_hooks.rb:49:in `each'
from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s
upport/lazy_load_hooks.rb:49:in `run_load_hooks'
from /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_re
cord/base.rb:324:in `<module:ActiveRecord>'
from /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_re
cord/base.rb:24:in `<top (required)>'
from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s
upport/dependencies.rb:293:in `require'
from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s
upport/dependencies.rb:293:in `block in require'
from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s
upport/dependencies.rb:259:in `load_dependency'
from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s
upport/dependencies.rb:293:in `require'
from /app/app/models/application_record.rb:1:in `<top (required)>'
from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s
upport/dependencies.rb:293:in `require'
from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s
upport/dependencies.rb:293:in `block in require'
from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s
upport/dependencies.rb:259:in `load_dependency'
from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s
upport/dependencies.rb:293:in `require'
from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s
upport/dependencies.rb:380:in `block in require_or_load'
from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s
upport/dependencies.rb:37:in `block in load_interlock'
from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s
upport/dependencies/interlock.rb:12:in `block in loading'
from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s
upport/concurrency/share_lock.rb:150:in `exclusive'
from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s
upport/dependencies/interlock.rb:11:in `loading'
from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s
upport/dependencies.rb:37:in `load_interlock'
from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s
upport/dependencies.rb:358:in `require_or_load'
from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s
upport/dependencies.rb:336:in `depend_on'
from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s
upport/dependencies.rb:252:in `require_dependency'
from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/engine.
rb:476:in `block (2 levels) in eager_load!'
from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/engine.
rb:475:in `each'
from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/engine.
rb:475:in `block in eager_load!'
from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/engine.
rb:473:in `each'
from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/engine.
rb:473:in `eager_load!'
from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/engine.
rb:354:in `eager_load!'
from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/applica
tion/finisher.rb:59:in `each'
from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/applica
tion/finisher.rb:59:in `block in <module:Finisher>'
from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/initial
izable.rb:30:in `instance_exec'
from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/initial
izable.rb:30:in `run'
from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/initial
izable.rb:55:in `block in run_initializers'
from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:228:in `block in tso
rt_each'
from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:350:in `block (2 lev
els) in each_strongly_connected_component'
from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:431:in `each_strongl
y_connected_component_from'
from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:349:in `block in eac
h_strongly_connected_component'
from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:347:in `each'
from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:347:in `call'
from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:347:in `each_strongl
y_connected_component'
from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'
from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'
from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/initial
izable.rb:54:in `run_initializers'
from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/applica
tion.rb:352:in `initialize!'
from /app/config/environment.rb:5:in `<top (required)>'
from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/applica
tion.rb:328:in `require'
from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/applica
tion.rb:328:in `require_environment!'
from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/command
s/commands_tasks.rb:157:in `require_application_and_environment!'
from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/command
s/commands_tasks.rb:77:in `console'
from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/command
s/commands_tasks.rb:49:in `run_command!'
from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/command
s.rb:18:in `<top (required)>'
from /app/bin/rails:4:in `require'
from /app/bin/rails:4:in `<main>'
My Gemfile
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.2'
# Use sqlite3 as the database for Active Record
group :production do
gem 'pg', '0.18.1'
gem 'rails_12factor'
end
group :development, :test do
gem 'sqlite3'
gem 'byebug'
end
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console', '>= 3.3.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
My Database.yml
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
# 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:
<<: *default
database: db/test.sqlite3
production:
<<: *default
database: db/production.sqlite3
You are setting sqlite as the default database with this code
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
So with this code it is getting set as sqlite because you are including the defualt values, which will not work on heroku because you cannot use sqlite on heroku.
production:
<<: *default
database: db/production.sqlite3
You should change the production database values in the database.yml file.
production:
adapter: postgresql
pool: 5
timeout: 5000
database: app_name
In your database.yml file change the production db to use postgresql as heroku doesn't support sqlite3.
For example:
production:
database: example_production
adapter: postgresql
host: localhost
password:
Briefing: I've been attempting to deploy my blog to heroku for the last week with no luck. I've contacted Heroku support and they've pretty much told me to post the log on stackoverflow. So here I am.
I'm pretty sure it has something to do with postgreSQL but I may be wrong. Anyway here's the codebase: www.github.com/apane/blogit_blog.
Heroku log below.
Gemfile provided for good measure:
source 'https://rubygems.org'
gem 'rails', '3.2.13'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'blogit', '0.8.0'
gem "will_paginate", "~> 3.0.4"
gem 'devise'
# Gems used only for assets and not required
# in production environments by default.
group :production do
gem 'pg'
gem "unicorn", "~> 4.6.2"
end
group :development, :test do
gem 'pg'
gem "unicorn", "~> 4.6.2"
end
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
Rake db:migrate error log:
rake aborted!
Please install the sqlite3 adapter: `gem install activerecord-sqlite3-adapter` (sqlite3 is not part of the bundle. Add it to Gemfile.)
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/bundler-1.1.5/lib/bundler/rubygems_integration.rb:147:in `block in replace_gem'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.13/lib/active_record/connection_adapters/sqlite3_adapter.rb:3:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:50:in `resolve_hash_connection'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:41:in `resolve_string_connection'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:25:in `spec'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:130:in `establish_connection'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.13/lib/active_record/railtie.rb:82:in `block (2 levels) in <class:Railtie>'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:26:in `block in on_load'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:25:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:25:in `on_load'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.13/lib/active_record/railtie.rb:74:in `block in <class:Railtie>'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
/Users/anthonypanepinto/Sites/personal_blog/personal_blog/config/environment.rb:5:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.13/lib/rails/application.rb:103:in `require_environment!'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.13/lib/rails/application.rb:297:in `block (2 levels) in initialize_tasks'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.4/lib/rake/task.rb:246:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.4/lib/rake/task.rb:246:in `block in execute'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.4/lib/rake/task.rb:241:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.4/lib/rake/task.rb:184:in `block in invoke_with_call_chain'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.4/lib/rake/task.rb:205:in `block in invoke_prerequisites'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.4/lib/rake/task.rb:203:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.4/lib/rake/task.rb:203:in `invoke_prerequisites'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.4/lib/rake/task.rb:183:in `block in invoke_with_call_chain'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.4/lib/rake/task.rb:170:in `invoke'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.4/lib/rake/application.rb:143:in `invoke_task'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.4/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.4/lib/rake/application.rb:101:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.4/lib/rake/application.rb:101:in `block in top_level'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.4/lib/rake/application.rb:110:in `run_with_threads'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.4/lib/rake/application.rb:95:in `top_level'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.4/lib/rake/application.rb:73:in `block in run'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.4/lib/rake/application.rb:160:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.4/lib/rake/application.rb:70:in `run'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)
It looks like you might be using sqlite in development.
Can you try this in your gemfile instead of what you have?
group :development, :test do
gem 'sqlite3'
gem "unicorn", "~> 4.6.2"
end
Then usual bundle install and run migration again.
The error Please install the sqlite3 adapter: 'gem install activerecord-sqlite3-adapter' is indicative of your local environment being configured to run SQLite, but SQLite isn't installed. The message references the activerecord-sqlite3-adapter gem, but within your Gemfile, within a fully integrated Rails environment, you'll only need to bundle the sqlite3 for the environment you want to run (presumably development & test, since your production is on Heroku, which uses Postgres).
Replace your group :development, test block in your Gemfile with the following:
group :development, :test do
gem 'sqlite3'
gem "unicorn", "~> 4.6.2"
end
Remember that Heroku uses the config property DATABASE_URL instead of your database.yml file for connecting to your db. Make sure it is set.
heroku config:set DATABASE_URL=sqlite3://bb06ca765fb123:71b6dabc#us-cdbr-east-04.cleardb.com/heroku_703eded6aebc123?reconnect=true
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'
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