fe_sendauth: no password supplied error with postgresql - ruby-on-rails

I am working on a new RoR app, and I keep recieving fe_sendauth: no password supplied when creating a new database. I have tried installing and reinstalling postgresql with no change.
Eric-Parks-MacBook-Pro:dearMe ericpark$ rake db:create
fe_sendauth: no password supplied
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `new'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:567:in `retrieve_connection'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_handling.rb:87:in `connection'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/tasks/postgresql_database_tasks.rb:8:in `connection'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/tasks/postgresql_database_tasks.rb:17:in `create'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/tasks/database_tasks.rb:93:in `create'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/tasks/database_tasks.rb:107:in `block in create_current'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/tasks/database_tasks.rb:275:in `block in each_current_configuration'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/tasks/database_tasks.rb:274:in `each'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/tasks/database_tasks.rb:274:in `each_current_configuration'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/tasks/database_tasks.rb:106:in `create_current'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/railties/databases.rake:17:in `block (2 levels) in <top (required)>'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/bin/rake:33:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "database"=>"dearMe_development"}
fe_sendauth: no password supplied
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `new'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:567:in `retrieve_connection'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_handling.rb:87:in `connection'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/tasks/postgresql_database_tasks.rb:8:in `connection'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/tasks/postgresql_database_tasks.rb:17:in `create'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/tasks/database_tasks.rb:93:in `create'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/tasks/database_tasks.rb:107:in `block in create_current'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/tasks/database_tasks.rb:275:in `block in each_current_configuration'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/tasks/database_tasks.rb:274:in `each'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/tasks/database_tasks.rb:274:in `each_current_configuration'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/tasks/database_tasks.rb:106:in `create_current'
/Users/ericpark/.rvm/gems/ruby-2.2.0/gems/activerecord-4.2.1/lib/active_record/railties/databases.rake:17:in `block (2 levels) in <top (required)>'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/Users/ericpark/.rvm/rubies/ruby-2.2.0/bin/rake:33:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "database"=>"dearMe_test"}
Eric-Parks-MacBook-Pro:dearMe ericpark$
database.yml
# PostgreSQL. Versions 8.2 and up are supported.
#
# Install the pg driver:
# gem install pg
# On OS X with Homebrew:
# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
# On OS X with MacPorts:
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
# On Windows:
# gem install pg
# Choose the win32 build.
# Install PostgreSQL and put its /bin directory on your path.
#
# Configure Using Gemfile
# gem 'pg'
#
default: &default
adapter: postgresql
encoding: unicode
# For details on connection pooling, see rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling
pool: 5
development:
<<: *default
database: dearMe_development
# The specified database role being used to connect to postgres.
# To create additional roles in postgres see `$ createuser --help`.
# When left blank, postgres will use the default role. This is
# the same name as the operating system user that initialized the database.
#username: dearMe
# The password associated with the postgres role (username).
#password:
# Connect on a TCP socket. Omitted by default since the client uses a
# domain socket that doesn't need configuration. Windows does not have
# domain sockets, so uncomment these lines.
#host: localhost
# The TCP port the server listens on. Defaults to 5432.
# If your server runs on a different port number, change accordingly.
#port: 5432
# Schema search path. The server defaults to $user,public
#schema_search_path: myapp,sharedapp,public
# Minimum log levels, in increasing order:
# debug5, debug4, debug3, debug2, debug1,
# log, notice, warning, error, fatal, and panic
# Defaults to warning.
#min_messages: notice
# 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: dearMe_test
# As with config/secrets.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
# ever seen by anyone, they now have access to your database.
#
# Instead, provide the password as a unix environment variable when you boot
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full rundown on how to provide these environment variables in a
# production deployment.
#
# On Heroku and other platform providers, you may have a full connection URL
# available as an environment variable. For example:
#
# DATABASE_URL="postgres://myuser:mypass#localhost/somedatabase"
#
# You can use this database configuration with:
#
# production:
# url: <%= ENV['DATABASE_URL'] %>
#
production:
<<: *default
database: dearMe_production
username: dearMe
password: <%= ENV['DEARME_DATABASE_PASSWORD'] %>
I believe I can set the password and username up within the database.yml, but what would I set them as?

You MUST add a password to your database, your database.yml should look something like this
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
development:
host: localhost
adapter: postgresql
database: databasename
user: papinotas
port: 5432
password: databasepassword
# 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

You should add password into your database.yml
default: &default
adapter: postgresql
encoding: unicode
# For details on connection pooling, see rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling
pool: 5
host: localhost
port: 5432
username: postgres
password: postgres
You can use the default password or create another one here.

Related

How to fix PG::InvalidParameterValue: ERROR:

Every time I try to run
bundle exec rake db:create db:migrate
I get this error:
PG::InvalidParameterValue: ERROR: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII)
HINT: Use the same encoding as in the template database, or use template0 as template.
: CREATE DATABASE "ruby-getting-started_development" ENCODING = 'unicode'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/postgresql/database_statements.rb:155:in `async_exec'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/postgresql/database_statements.rb:155:in `block in execute'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:484:in `block in log'
/usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.8/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:478:in `log'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/postgresql/database_statements.rb:154:in `execute'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/postgresql/schema_statements.rb:78:in `create_database'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/tasks/postgresql_database_tasks.rb:15:in `create'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/tasks/database_tasks.rb:93:in `create'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/tasks/database_tasks.rb:107:in `block in create_current'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/tasks/database_tasks.rb:276:in `block in each_current_configuration'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/tasks/database_tasks.rb:275:in `each'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/tasks/database_tasks.rb:275:in `each_current_configuration'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/tasks/database_tasks.rb:106:in `create_current'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/railties/databases.rake:17:in `block (2 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `block in execute'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `each'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `execute'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/task.rb:194:in `block in invoke_with_call_chain'
/usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/task.rb:187:in `invoke_with_call_chain'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/task.rb:180:in `invoke'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/application.rb:152:in `invoke_task'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `block (2 levels) in top_level'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `each'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `block in top_level'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/application.rb:117:in `run_with_threads'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/application.rb:102:in `top_level'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/application.rb:80:in `block in run'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/application.rb:77:in `run'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.3.0/bin/rake:23:in `load'
/usr/local/rvm/gems/ruby-2.3.0/bin/rake:23:in `<main>'
/usr/local/rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
/usr/local/rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "database"=>"ruby-getting-started_development"}
PG::InvalidParameterValue: ERROR: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII)
HINT: Use the same encoding as in the template database, or use template0 as template.
: CREATE DATABASE "ruby-getting-started_test" ENCODING = 'unicode'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/postgresql/database_statements.rb:155:in `async_exec'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/postgresql/database_statements.rb:155:in `block in execute'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:484:in `block in log'
/usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.8/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:478:in `log'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/postgresql/database_statements.rb:154:in `execute'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/postgresql/schema_statements.rb:78:in `create_database'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/tasks/postgresql_database_tasks.rb:15:in `create'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/tasks/database_tasks.rb:93:in `create'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/tasks/database_tasks.rb:107:in `block in create_current'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/tasks/database_tasks.rb:276:in `block in each_current_configuration'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/tasks/database_tasks.rb:275:in `each'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/tasks/database_tasks.rb:275:in `each_current_configuration'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/tasks/database_tasks.rb:106:in `create_current'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/railties/databases.rake:17:in `block (2 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `block in execute'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `each'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `execute'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/task.rb:194:in `block in invoke_with_call_chain'
/usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/task.rb:187:in `invoke_with_call_chain'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/task.rb:180:in `invoke'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/application.rb:152:in `invoke_task'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `block (2 levels) in top_level'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `each'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `block in top_level'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/application.rb:117:in `run_with_threads'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/application.rb:102:in `top_level'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/application.rb:80:in `block in run'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/lib/rake/application.rb:77:in `run'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.3.0/bin/rake:23:in `load'
/usr/local/rvm/gems/ruby-2.3.0/bin/rake:23:in `<main>'
/usr/local/rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
/usr/local/rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "database"=>"ruby-getting-started_test"}
rake aborted!
ActiveRecord::NoDatabaseError: FATAL: database "ruby-getting-started_development" does not exist
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:661:in `rescue in connect'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:571:in `retrieve_connection'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_handling.rb:87:in `connection'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/migration.rb:916:in `initialize'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/migration.rb:823:in `new'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/migration.rb:823:in `up'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/migration.rb:801:in `migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
/usr/local/rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'
PG::ConnectionBad: FATAL: database "ruby-getting-started_development" does not exist
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `new'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:571:in `retrieve_connection'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_handling.rb:87:in `connection'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/migration.rb:916:in `initialize'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/migration.rb:823:in `new'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/migration.rb:823:in `up'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/migration.rb:801:in `migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.8/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
/usr/local/rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
This is what my database.yml file looks like
# PostgreSQL. Versions 8.2 and up are supported.
#
# Install the pg driver:
# gem install pg
# On OS X with Homebrew:
# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
# On OS X with MacPorts:
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
# On Windows:
# gem install pg
# Choose the win32 build.
# Install PostgreSQL and put its /bin directory on your path.
#
# Configure Using Gemfile
# gem 'pg'
#
default: &default
adapter: postgresql
encoding: unicode
# For details on connection pooling, see rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling
pool: 5
development:
<<: *default
database: ruby-getting-started_development
# The specified database role being used to connect to postgres.
# To create additional roles in postgres see `$ createuser --help`.
# When left blank, postgres will use the default role. This is
# the same name as the operating system user that initialized the database.
#username: ruby-getting-started
# The password associated with the postgres role (username).
#password:
# Connect on a TCP socket. Omitted by default since the client uses a
# domain socket that doesn't need configuration. Windows does not have
# domain sockets, so uncomment these lines.
#host: localhost
# The TCP port the server listens on. Defaults to 5432.
# If your server runs on a different port number, change accordingly.
#port: 5432
# Schema search path. The server defaults to $user,public
#schema_search_path: myapp,sharedapp,public
# Minimum log levels, in increasing order:
# debug5, debug4, debug3, debug2, debug1,
# log, notice, warning, error, fatal, and panic
# Defaults to warning.
#min_messages: notice
# 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: ruby-getting-started_test
# As with config/secrets.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
# ever seen by anyone, they now have access to your database.
#
# Instead, provide the password as a unix environment variable when you boot
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full rundown on how to provide these environment variables in a
# production deployment.
#
# On Heroku and other platform providers, you may have a full connection URL
# available as an environment variable. For example:
#
# DATABASE_URL="postgres://myuser:mypass#localhost/somedatabase"
#
# You can use this database configuration with:
#
# production:
# url: <%= ENV['DATABASE_URL'] %>
#
production:
<<: *default
database: ruby-getting-started_production
username: ruby-getting-started
password: <%= ENV['RUBY-GETTING-STARTED_DATABASE_PASSWORD'] %>
Does anyone know how to fix it?
Similar question asked here. That answer also applies to your question.
Every DB you create in postgres copies template1 DB (it is system DB). The issue you have is that, the encoding of template1 DB is not unicode. So you have two options, (a) change encoding of template1 to unicode or (b) use template0 to create new databases in postgres. template0 is a system database without the encoding information, so it uses the encoding specified. Below solution uses option-b.
Make the below change to your database.yml file:
development:
<<: *default
database: ruby-getting-started_development
template: template0

ActiveRecord::No Database Error Fatal: Role "..."does not exist

I'm working a project collaboratively with others. It is deployed to heroku and it we're using postgresql.
I want to make changes in a local branch and see my changes in the web browser right away.
How can I do this with heroku?
I'm working in Cloud9 development environment and I used to enter "rails s -p $PORT -b $IP" to view my changes in the app, but now when I do that, I get a "no database error."
I've tried googling things but I'm still confused. How can I make changes to an exisiting app and see my changes locally (without pushing to origin/master)? I've never worked with databases before... using the pre-programmed cloud9, things were just working. I'm not sure how to create a separate database for heroku if that's what is needed.
Here is a copy of 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
# FOR HEROKU -- POSTGRES DB SETUP
# UNCOMMENT WHEN WORKING LOCALLY.
development:
adapter: postgresql
database: planit_developement
pool: 5
timeout: 5000
test:
adapter: postgresql
database: planit_test
pool: 5
timeout: 5000
# production:
# <<: *default
# database: db/production.sqlite3
Here is the full trace when I try to migrate:
rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
rake aborted!
ActiveRecord::NoDatabaseError: FATAL: role "ubuntu" does not exist
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql_adapter.rb:665:in `rescue in connect'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql_adapter.rb:655:in `connect'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:571:in `retrieve_connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/connection_handling.rb:87:in `connection'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/migration.rb:913:in `initialize'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/migration.rb:820:in `new'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/migration.rb:820:in `up'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/migration.rb:798:in `migrate'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.4/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:75:in `run'
Tasks: TOP => db:migrate

FATAL: role "root" does not exist

I trying to create rails application with postgresql database, but when I create database rake db:migrate bash show me an error
FATAL: role "my" does not exist
how fix?
sorry for my bad English
UPD
my#my-P5K-SE ~/ror/timonin $ rake db:create
FATAL: role "my" does not exist
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:898:in `rescue in connect'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `connect'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:568:in `initialize'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `new'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `postgresql_connection'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:435:in `new_connection'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:445:in `checkout_new_connection'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `acquire_connection'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:351:in `block in checkout'
/usr/local/rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:350:in `checkout'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection'
/usr/local/rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:541:in `retrieve_connection'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/connection_handling.rb:87:in `connection'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/tasks/postgresql_database_tasks.rb:8:in `connection'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/tasks/postgresql_database_tasks.rb:17:in `create'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/tasks/database_tasks.rb:88:in `create'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/tasks/database_tasks.rb:102:in `block in create_current'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/tasks/database_tasks.rb:209:in `block in each_current_configuration'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/tasks/database_tasks.rb:208:in `each'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/tasks/database_tasks.rb:208:in `each_current_configuration'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/tasks/database_tasks.rb:101:in `create_current'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/railties/databases.rake:17:in `block (2 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/lib/rake/task.rb:240:in `call'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/lib/rake/task.rb:240:in `block in execute'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/lib/rake/task.rb:235:in `each'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/lib/rake/task.rb:235:in `execute'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/local/rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/lib/rake/task.rb:165:in `invoke'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/lib/rake/application.rb:150:in `invoke_task'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/lib/rake/application.rb:106:in `each'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/lib/rake/application.rb:106:in `block in top_level'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/lib/rake/application.rb:115:in `run_with_threads'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/lib/rake/application.rb:100:in `top_level'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/lib/rake/application.rb:78:in `block in run'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/lib/rake/application.rb:176:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/lib/rake/application.rb:75:in `run'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/bin/rake:33:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.1.3/bin/rake:23:in `load'
/usr/local/rvm/gems/ruby-2.1.3/bin/rake:23:in `<main>'
/usr/local/rvm/gems/ruby-2.1.3/bin/ruby_executable_hooks:15:in `eval'
/usr/local/rvm/gems/ruby-2.1.3/bin/ruby_executable_hooks:15:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "database"=>"timonin_development"}
FATAL: role "my" does not exist
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:898:in `rescue in connect'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `connect'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:568:in `initialize'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `new'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `postgresql_connection'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:435:in `new_connection'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:445:in `checkout_new_connection'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `acquire_connection'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:351:in `block in checkout'
/usr/local/rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:350:in `checkout'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection'
/usr/local/rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:541:in `retrieve_connection'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/connection_handling.rb:87:in `connection'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/tasks/postgresql_database_tasks.rb:8:in `connection'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/tasks/postgresql_database_tasks.rb:17:in `create'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/tasks/database_tasks.rb:88:in `create'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/tasks/database_tasks.rb:102:in `block in create_current'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/tasks/database_tasks.rb:209:in `block in each_current_configuration'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/tasks/database_tasks.rb:208:in `each'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/tasks/database_tasks.rb:208:in `each_current_configuration'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/tasks/database_tasks.rb:101:in `create_current'
/usr/local/rvm/gems/ruby-2.1.3/gems/activerecord-4.1.4/lib/active_record/railties/databases.rake:17:in `block (2 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/lib/rake/task.rb:240:in `call'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/lib/rake/task.rb:240:in `block in execute'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/lib/rake/task.rb:235:in `each'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/lib/rake/task.rb:235:in `execute'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/local/rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/lib/rake/task.rb:165:in `invoke'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/lib/rake/application.rb:150:in `invoke_task'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/lib/rake/application.rb:106:in `each'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/lib/rake/application.rb:106:in `block in top_level'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/lib/rake/application.rb:115:in `run_with_threads'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/lib/rake/application.rb:100:in `top_level'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/lib/rake/application.rb:78:in `block in run'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/lib/rake/application.rb:176:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/lib/rake/application.rb:75:in `run'
/usr/local/rvm/gems/ruby-2.1.3/gems/rake-10.3.2/bin/rake:33:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.1.3/bin/rake:23:in `load'
/usr/local/rvm/gems/ruby-2.1.3/bin/rake:23:in `<main>'
/usr/local/rvm/gems/ruby-2.1.3/bin/ruby_executable_hooks:15:in `eval'
/usr/local/rvm/gems/ruby-2.1.3/bin/ruby_executable_hooks:15:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "database"=>"timonin_test"}
database.yml
# PostgreSQL. Versions 8.2 and up are supported.
#
# Install the pg driver:
# gem install pg
# On OS X with Homebrew:
# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
# On OS X with MacPorts:
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
# On Windows:
# gem install pg
# Choose the win32 build.
# Install PostgreSQL and put its /bin directory on your path.
#
# Configure Using Gemfile
# gem 'pg'
#
default: &default
adapter: postgresql
encoding: unicode
# For details on connection pooling, see rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling
pool: 5
development:
<<: *default
database: timonin_development
# The specified database role being used to connect to postgres.
# To create additional roles in postgres see `$ createuser --help`.
# When left blank, postgres will use the default role. This is
# the same name as the operating system user that initialized the database.
#username: timonin
# The password associated with the postgres role (username).
#password:
# Connect on a TCP socket. Omitted by default since the client uses a
# domain socket that doesn't need configuration. Windows does not have
# domain sockets, so uncomment these lines.
#host: localhost
# The TCP port the server listens on. Defaults to 5432.
# If your server runs on a different port number, change accordingly.
#port: 5432
# Schema search path. The server defaults to $user,public
#schema_search_path: myapp,sharedapp,public
# Minimum log levels, in increasing order:
# debug5, debug4, debug3, debug2, debug1,
# log, notice, warning, error, fatal, and panic
# Defaults to warning.
#min_messages: notice
# 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: timonin_test
# As with config/secrets.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
# ever seen by anyone, they now have access to your database.
#
# Instead, provide the password as a unix environment variable when you boot
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full rundown on how to provide these environment variables in a
# production deployment.
#
# On Heroku and other platform providers, you may have a full connection URL
# available as an environment variable. For example:
#
# DATABASE_URL="postgres://myuser:mypass#localhost/somedatabase"
#
# You can use this database configuration with:
#
# production:
# url: <%= ENV['DATABASE_URL'] %>
#
production:
<<: *default
database: timonin_production
username: timonin
password: <%= ENV['TIMONIN_DATABASE_PASSWORD'] %>
You can connect to Postgres server with explicit (my i.e. OS username) or implicit (timonin i.e. role in database.yml) login.
As I see your database.yml has username statement, but only for production environment. Running rake tests without specifying Rails environment will run them against development environment by default. That is why you have error like FATAL: role "my" does not exist.
So depending on your needs you have to add these statements to all databases' defenitions (test and development as well):
username: timonin
password: <%= ENV['TIMONIN_DATABASE_PASSWORD'] %>
After that you Rails application will connect as timonin user.
Full checklist is the following:
Create role
Here is SQL for PostgreSQL:
CREATE ROLE timonin LOGIN PASSWORD 'Pas$_sword'
NOINHERIT CREATEDB
VALID UNTIL 'infinity';
COMMENT ON ROLE timonin
IS 'Timonin database role for Rails app';
Uncomment or add statements username: timonin and password: <%= ENV['TIMONIN_DATABASE_PASSWORD'] %> to your database.yml file
Run all operations with TIMONIN_DATABASE_PASSWORD variable:
Here is changed rake command:
rake db:create TIMONIN_DATABASE_PASSWORD='Pas$_sword'
or:
rake db:create TIMONIN_DATABASE_PASSWORD='Pas$_sword' RAILS_ENV=test
for test environment.
I had the same problem while using Ubuntu 14.04 LTS for my Ruby on Rails installation. The problem was that I had not created a user for my postgres database so I did the following and it worked.
#1 logged in as default user
$sudo su postgres
#2 login into the postgres interactive terminal
psql
Alternatively, you can combine step #1 and #2 as follows:
$sudo su postgres psql
#3 View a list of roles while in the postgres interative terminal
postgres=# \du
#4 create role in the postgres database
postgres=# CREATE user with password '';
#5 Make the user your have just created a superuser
postgres=# alter user with superuser;
#6 Quit from the postgres console
postgres=# \q

Trouble installing gitlab-5.0 - rake aborted

Trouble installing gitlab-5.0
https://github.com/gitlabhq/gitlabhq/blob/5-0-stable/doc/install/installation.md#initialise-database-and-activate-advanced-features
root#ubuntu:/home/gitlab/gitlab# bundle exec rake gitlab:setup RAILS_ENV=production
rake aborted!
Access denied for user 'root'#'localhost' (using password: YES)
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `connect'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `initialize'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `new'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `mysql2_connection'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/model_schema.rb:308:in `clear_cache!'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/railtie.rb:104:in `block (2 levels) in <class:Railtie>'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:418:in `_run__807030537706508428__prepare__2182945095053453794__callbacks'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `__run_callback'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:385:in `_run_prepare_callbacks'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:81:in `run_callbacks'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/reloader.rb:74:in `prepare!'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/reloader.rb:48:in `prepare!'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application/finisher.rb:47:in `block in <module:Finisher>'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
/home/gitlab/gitlab/config/environment.rb:5:in `<top (required)>'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/backports-2.6.7/lib/backports/tools.rb:314:in `require'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/backports-2.6.7/lib/backports/tools.rb:314:in `require_with_backports'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:103:in `require_environment!'
/home/gitlab/gitlab/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:297:in `block (2 levels) in initialize_tasks'
Tasks: TOP => gitlab:setup => environment
(See full trace by running task with --trace)
Some idea?
If you are following the tutorial and followed the steps for the MySQL database setup then you have configured the database to use gitlab for the user name.
# Create a user for GitLab. (change $password to a real password)
mysql> CREATE USER 'gitlab'#'localhost' IDENTIFIED BY '$password';
but if your database.yml file is attempting to log into the database using the root credentials.
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: gitlabhq_production
pool: 5
username: root
password: "secure password"
# host: localhost
# socket: /tmp/mysql.sock
That is why you would see that error.
Change your database.yml file to reflect the login created in the database setup portion of the tutorial.
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: gitlabhq_production
pool: 5
username: gitlab
password: "$password"
# host: localhost
# socket: /tmp/mysql.sock
That section Initialise Database and Activate Advanced Features is:
sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
That means you are supposed to execute that command as git, not as root (which hasn't been granted access to the database).
Make sure though that your database.yml config file looks like this one (if you have mysql installed and want to use a mysql database).
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: gitlabhq_production
pool: 5
username: root
password: "secure password"
# host: localhost
# socket: /tmp/mysql.sock
It does declare an access for an account root, but this is purely a declarative mysql account (nothing to do with the user root)

Rails rake aborted! can't convert Hash into String

Ok i had this working and i'm not sure what i could have changed to make rake db:create not working now. I ran rake db:drop to drop my db so i can start from scratch and now rake db:create is having a problem.
Here's my stacktrace below. I'm not sure how to go about troubleshooting this.
$ rake db:create --trace
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:create
rake aborted!
can't convert Hash into String
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `connect'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `initialize'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/activerecord-3.1.8/lib/active_record/connection_adapters/mysql2_adapter.rb:17:in `new'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/activerecord-3.1.8/lib/active_record/connection_adapters/mysql2_adapter.rb:17:in `mysql2_connection'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/activerecord-3.1.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:304:in `new_connection'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/activerecord-3.1.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:323:in `checkout_new_connection'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/activerecord-3.1.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block (2 levels) in checkout'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/activerecord-3.1.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:261:in `loop'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/activerecord-3.1.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:261:in `block in checkout'
/Users/TomCaflisch/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/activerecord-3.1.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:260:in `checkout'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/activerecord-3.1.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:162:in `connection'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/activerecord-3.1.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:409:in `retrieve_connection'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/activerecord-3.1.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:115:in `retrieve_connection'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/activerecord-3.1.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:89:in `connection'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/activerecord-3.1.8/lib/active_record/railties/databases.rake:86:in `rescue in create_database'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/activerecord-3.1.8/lib/active_record/railties/databases.rake:54:in `create_database'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/activerecord-3.1.8/lib/active_record/railties/databases.rake:42:in `block (2 levels) in <top (required)>'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/lib/rake/task.rb:227:in `call'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/lib/rake/task.rb:227:in `block in execute'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/lib/rake/task.rb:222:in `each'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/lib/rake/task.rb:222:in `execute'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/Users/TomCaflisch/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/lib/rake/task.rb:159:in `invoke_with_call_chain'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/lib/rake/task.rb:152:in `invoke'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/lib/rake/application.rb:141:in `invoke_task'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/lib/rake/application.rb:99:in `block (2 levels) in top_level'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/lib/rake/application.rb:99:in `each'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/lib/rake/application.rb:99:in `block in top_level'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/lib/rake/application.rb:108:in `run_with_threads'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/lib/rake/application.rb:93:in `top_level'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/lib/rake/application.rb:71:in `block in run'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/lib/rake/application.rb:158:in `standard_exception_handling'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/lib/rake/application.rb:68:in `run'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/gems/rake-10.0.2/bin/rake:37:in `<top (required)>'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/bin/rake:19:in `load'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/bin/rake:19:in `<main>'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/bin/ruby_noexec_wrapper:14:in `eval'
/Users/TomCaflisch/.rvm/gems/ruby-1.9.3-p327#famnfo/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => db:create
database.yml
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
development:
adapter: mysql2
encoding: utf8
database: FamNFo_development
# local
username: root
password:
# server
# username: famnfo_dev
# password: Panther89!1
# local
socket: /tmp/mysql.sock
# server
# socket: /var/lib/mysql/mysql.sock
# 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: mysql2
encoding: utf8
database: FamNFo_test
# local
# username: root
# password:
# server
username: root
password:
# local
socket: /tmp/mysql.sock
# server
#socket: /var/lib/mysql/mysql.sock
production:
adapter: mysql2
encoding: utf8
database: FamNFo_production
# local
# username: root
# password:
# server
username: myusername
password: mypassword
# local
# socket: /tmp/mysql.sock
# server
socket: /var/lib/mysql/mysql.sock
When you have extra leading spaces before a key in your YAML file it is interpreted as a sub-key, and thus the upper key is interpreted as a hash instead of a string. So removing the extra space before socket in the test section should fix the problem.

Resources