正在运行rake db:create
无效。这是堆栈跟踪:
/Users/mounikasmitha/.rvm/gems/ruby-2.4.0/gems/activesupport-3.2.13/lib/active_support/values/time_zone.rb:270: warning: circular argument reference - now
rake aborted!
LoadError: Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to your Gemfile.)
/Users/mounikasmitha/.rvm/gems/ruby-2.4.0/gems/bundler-1.15.2/lib/bundler/rubygems_integration.rb:377:in `block (2 levels) in replace_gem'
/Users/mounikasmitha/.rvm/gems/ruby-2.4.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:7:in `<top (required)>'
/Users/mounikasmitha/.rvm/gems/ruby-2.4.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
/Users/mounikasmitha/.rvm/gems/ruby-2.4.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
/Users/mounikasmitha/.rvm/gems/ruby-2.4.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
/Users/mounikasmitha/.rvm/gems/ruby-2.4.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
/Users/mounikasmitha/.rvm/gems/ruby-2.4.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:50:in `resolve_hash_connection'
/Users/mounikasmitha/.rvm/gems/ruby-2.4.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:29:in `spec'
/Users/mounikasmitha/.rvm/gems/ruby-2.4.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:130:in `establish_connection'
/Users/mounikasmitha/.rvm/gems/ruby-2.4.0/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:101:in `create_database'
/Users/mounikasmitha/.rvm/gems/ruby-2.4.0/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:62:in `block (3 levels) in <top (required)>'
/Users/mounikasmitha/.rvm/gems/ruby-2.4.0/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:62:in `each'
/Users/mounikasmitha/.rvm/gems/ruby-2.4.0/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:62:in `block (2 levels) in <top (required)>'
/Users/mounikasmitha/.rvm/gems/ruby-2.4.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
/Users/mounikasmitha/.rvm/gems/ruby-2.4.0/bin/ruby_executable_hooks:15:in `eval'
/Users/mounikasmitha/.rvm/gems/ruby-2.4.0/bin/ruby_executable_hooks:15:in `<main>'
Gem::LoadError: pg is not part of the bundle. Add it to your Gemfile.
/Users/mounikasmitha/.rvm/gems/ruby-2.4.0/gems/bundler-1.15.2/lib/bundler/rubygems_integration.rb:377:in `block (2 levels) in replace_gem'
/Users/mounikasmitha/.rvm/gems/ruby-2.4.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:7:in `<top (required)>'
/Users/mounikasmitha/.rvm/gems/ruby-2.4.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
/Users/mounikasmitha/.rvm/gems/ruby-2.4.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
/Users/mounikasmitha/.rvm/gems/ruby-2.4.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
/Users/mounikasmitha/.rvm/gems/ruby-2.4.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
/Users/mounikasmitha/.rvm/gems/ruby-2.4.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:50:in `resolve_hash_connection'
/Users/mounikasmitha/.rvm/gems/ruby-2.4.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:29:in `spec'
/Users/mounikasmitha/.rvm/gems/ruby-2.4.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:130:in `establish_connection'
/Users/mounikasmitha/.rvm/gems/ruby-2.4.0/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:101:in `create_database'
/Users/mounikasmitha/.rvm/gems/ruby-2.4.0/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:62:in `block (3 levels) in <top (required)>'
/Users/mounikasmitha/.rvm/gems/ruby-2.4.0/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:62:in `each'
/Users/mounikasmitha/.rvm/gems/ruby-2.4.0/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:62:in `block (2 levels) in <top (required)>'
/Users/mounikasmitha/.rvm/gems/ruby-2.4.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
/Users/mounikasmitha/.rvm/gems/ruby-2.4.0/bin/ruby_executable_hooks:15:in `eval'
/Users/mounikasmitha/.rvm/gems/ruby-2.4.0/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => db:create
(See full trace by running task with --trace)
答案 0 :(得分:3)
错误说:
pg不是捆绑包的一部分。将它添加到您的Gemfile中。
为此,只需转到您的Rails应用程序目录并打开Gemfile
并将以下内容放入其中。
# Use PostgreSQL as the database for Active Record
gem 'pg'
database.yml的
default: &default
adapter: postgresql
encoding: unicode
pool: 5
username: postgres
password:
timeout: 5000
development:
<<: *default
database: myawesomeapp_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:
<<: *default
database: myawesomeapp_test
production:
<<: *default
database: myawesomeapp_prod
在您添加了该行之后,保存您的文件并点击您的rails app目录中的bundle install
以安装所需的gem。
还要确保在PostgreSQL实例上有一个允许connect
和create
个新数据库的用户。您不需要自己创建数据库。