ActiveRecord::ConnectionNotEstablished with postgres - ruby-on-rails

I'm getting the below exception while migrating data from JIRA to Redmine using the script provided on the official redmine website (the Luciano Pacheco, 2011-06-07 06:28 version):
-bash-4.1$ rake --trace jira_migration:do_all_migrations RAILS_ENV="production"
rake aborted!
ActiveRecord::ConnectionNotEstablished
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/model_schema.rb:223:in `table_exists?'
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/attribute_methods/primary_key.rb:75:in `get_primary_key'
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/attribute_methods/primary_key.rb:60:in `reset_primary_key'
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/attribute_methods/primary_key.rb:49:in `primary_key'
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/attribute_assignment.rb:13:in `attributes_protected_by_default'
/usr/local/lib/ruby/gems/1.9.1/gems/activemodel-3.2.13/lib/active_model/mass_assignment_security.rb:216:in `block in protected_attributes_configs'
/usr/local/lib/ruby/gems/1.9.1/gems/activemodel-3.2.13/lib/active_model/mass_assignment_security.rb:188:in `yield'
/usr/local/lib/ruby/gems/1.9.1/gems/activemodel-3.2.13/lib/active_model/mass_assignment_security.rb:188:in `default'
/usr/local/lib/ruby/gems/1.9.1/gems/activemodel-3.2.13/lib/active_model/mass_assignment_security.rb:188:in `protected_attributes'
/usr/local/lib/ruby/gems/1.9.1/gems/activemodel-3.2.13/lib/active_model/mass_assignment_security.rb:118:in `block in attr_protected'
/usr/local/lib/ruby/gems/1.9.1/gems/activemodel-3.2.13/lib/active_model/mass_assignment_security.rb:117:in `each'
/usr/local/lib/ruby/gems/1.9.1/gems/activemodel-3.2.13/lib/active_model/mass_assignment_security.rb:117:in `attr_protected'
/opt/redmine/redmine/app/models/tracker.rb:38:in `<class:Tracker>'
/opt/redmine/redmine/app/models/tracker.rb:18:in `<top (required)>'
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
/opt/redmine/redmine-2.3.3/lib/tasks/migrate_jira.rake:5:in `<top (required)>'
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `load'
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `block in load'
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `load'
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:425:in `block in load_tasks'
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:425:in `each'
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:425:in `load_tasks'
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:145:in `load_tasks'
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
/opt/redmine/redmine-2.3.3/Rakefile:7:in `<top (required)>'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/rake_module.rb:25:in `load'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/rake_module.rb:25:in `load_rakefile'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:637:in `raw_load_rakefile'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:94:in `block in load_rakefile'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:93:in `load_rakefile'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:77:in `block in run'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/usr/local/bin/rake:23:in `load'
/usr/local/bin/rake:23:in `<main>'
-bash-4.1$
My database.yml looks like this (only the postgres production section is active):
# Default setup is given for MySQL with ruby1.9. If you're running Redmine
# with MySQL and ruby1.8, replace the adapter name with `mysql`.
# Examples for PostgreSQL, SQLite3 and SQL Server can be found at the end.
# Line indentation must be 2 spaces (no tabs).
#production:
# adapter: mysql2
# database: redmine
# host: localhost
# port: 3306
# username: root
# password: ""
# encoding: utf8
#development:
# adapter: mysql2
# database: redmine_development
# host: localhost
# username: root
# password: ""
# encoding: utf8
# 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
# database: redmine_test
# host: localhost
# username: root
# password: ""
# encoding: utf8
# PostgreSQL configuration example
production:
adapter: postgresql
database: redmine
host: localhost
port: 5432
username: redmine
password: "canBeCrackedPrettyFast"
# SQLite3 configuration example
#production:
# adapter: sqlite3
# database: db/redmine.sqlite3
# SQL Server configuration example
#production:
# adapter: sqlserver
# database: redmine
# host: localhost
# username: jenkins
# password: jenkins
Now, in my postgres.conf I turned on the
log_connections = on
log_disconnections = on
options so I can see when exactly the session starts and stops. When I access my redmine database using the psql client I can immediately see the expected log entry (it just states that redmine user has logged in and logged out, apologies for non-english messages):
2013-10-10 16:18:53 CESTLOG: Verbindung empfangen: Host=172.30.5.77 Port=48393
2013-10-10 16:18:53 CESTLOG: Verbindung authorisiert: Benutzer=redmine Datenbank=redmine
2013-10-10 16:18:57 CESTLOG: Verbindungsende: Sitzungszeit: 0:00:06.710 Benutzer=redmine Datenbank=redmine Host=172.30.5.77 port=48393
However, when I run the above mentioned script, nothing gets logged, which makes me think the ActiveRecord doesn't load the data from my database.yml or loads it uncorrectly. My question is: are there any standard ActiveRecord settings that need to be overridden? If not, how should I proceed from here? I'm out of ideas at this point.

Related

use mysql as persistence motor in ruby on rails

I need to change sqlite to mysql for work with ruby on rails, but as I am a newbie in this, I have a problem
The first that I did was to go a GemFile and include the mysql gem. I am working in local
localhost:3306 using LAMP
source 'https://rubygems.org'
gem 'rails', '3.2.19'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2'
gem 'hirb'
After I configurate the file database.yml
development:
adapter: mysql2
encoding: utf8
database: blog_development
pool: 5
username: root
password: strlen12
socket: /tmp/mysql.sock
test:
adapter: mysql2
encoding: utf8
database: blog_development
pool: 5
username: root
password: strlen12
socket: /tmp/mysql.sock
production:
adapter: mysql2
encoding: utf8
database: blog_development
pool: 5
username: root
password: strlen12
socket: /tmp/mysql.sock
but when I try to run rake db:migrate this error is triggered
fernando#fernando:~/ProyectoTicketMaster/TicketMaster$ rake db:migrate
rake aborted!
Mysql2::Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/mysql2-0.3.17/lib/mysql2/client.rb:70:in `connect'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/mysql2-0.3.17/lib/mysql2/client.rb:70:in `initialize'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/activerecord-3.2.19/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `new'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/activerecord-3.2.19/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `mysql2_connection'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/activerecord-3.2.19/lib/active_record/model_schema.rb:310:in `clear_cache!'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/activerecord-3.2.19/lib/active_record/railtie.rb:103:in `block (2 levels) in <class:Railtie>'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/activesupport-3.2.19/lib/active_support/callbacks.rb:418:in `_run__875551666__prepare__678451887__callbacks'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/activesupport-3.2.19/lib/active_support/callbacks.rb:405:in `__run_callback'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/activesupport-3.2.19/lib/active_support/callbacks.rb:385:in `_run_prepare_callbacks'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/activesupport-3.2.19/lib/active_support/callbacks.rb:81:in `run_callbacks'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/actionpack-3.2.19/lib/action_dispatch/middleware/reloader.rb:74:in `prepare!'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/actionpack-3.2.19/lib/action_dispatch/middleware/reloader.rb:48:in `prepare!'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/railties-3.2.19/lib/rails/application/finisher.rb:47:in `block in <module:Finisher>'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/railties-3.2.19/lib/rails/initializable.rb:30:in `instance_exec'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/railties-3.2.19/lib/rails/initializable.rb:30:in `run'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/railties-3.2.19/lib/rails/initializable.rb:55:in `block in run_initializers'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/railties-3.2.19/lib/rails/initializable.rb:54:in `each'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/railties-3.2.19/lib/rails/initializable.rb:54:in `run_initializers'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/railties-3.2.19/lib/rails/application.rb:136:in `initialize!'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/railties-3.2.19/lib/rails/railtie/configurable.rb:30:in `method_missing'
/home/fernando/ProyectoTicketMaster/TicketMaster/config/environment.rb:5:in `<top (required)>'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:251:in `require'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:251:in `block in require'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:236:in `load_dependency'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:251:in `require'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/railties-3.2.19/lib/rails/application.rb:103:in `require_environment!'
/home/fernando/.rvm/gems/ruby-1.9.3-p547#ticket_master/gems/railties-3.2.19/lib/rails/application.rb:305:in `block (2 levels) in initialize_tasks'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)
Version of Mysql installed in my pc
fernando#fernando:~/ProyectoTicketMaster/TicketMaster$ mysql --version
mysql Ver 14.14 Distrib 5.5.38, for debian-linux-gnu (i686) using readline 6.2
Check the socket path for MySQL in your file my.cnf (usually in the /etc/mysql/ folder) :
socket=/var/lib/mysql/mysql.sock
you can check if mysql is running with the following command:
mysqladmin -u root -p status
If you make any changes make sure you restart your server. Also you could use the localhost connection:
development:
adapter: mysql2
encoding: utf8
database: my_db_name
username: root
password: my_password
host: 127.0.0.1
port: 3306

Ruby On Rails Mysql Access Denied

Im trying to excute the following command on a new rails project on my Ubuntu Server.
rails g scaffold User email:string username:string
but Im receiving the following error:
"/usr/local/rvm/gems/ruby-1.9.3-p392/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `connect': Access denied for user 'root'#'localhost' (using password: YES) (Mysql2::Error)
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `initialize'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `new'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `mysql2_connection'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout'
from /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection'
from /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record/railtie.rb:88:in `block in <class:Railtie>'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /home/rails/membershipServices/config/environment.rb:6:in `<top (required)>'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/application.rb:103:in `require'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/application.rb:103:in `require_environment!'
from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands.rb:25:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I have tried accessing mysql thru my server with the credentials provided in database.yml and I can login just fine. But for some reason I can't do it via Ruby on Rails command. My database.yml is:
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MYSQL driver
# gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
# gem 'mysql2'
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: membershipServices_development
pool: 5
username: root
password: ******
socket: /var/run/mysqld/mysqld.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
reconnect: false
database: membershipServices_test
pool: 5
username: root
password: ******
socket: /var/run/mysqld/mysqld.sock
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: membershipServices_production
pool: 5
username: root
password: ******
host: localhost
socket: /var/run/mysqld/mysqld.sock
Again I verified that username and password provided was correct by logging into mysql via terminal on my server. Thanks for your help in advance!
I was doing some more research on this website and was able to try different things. The only thing that helped me was renaming the username to root1 root2 and root3 to verify which environment it was using. After doing so I verified Development was being used. I added Host: localhost to my Development connection information and that did the trick.

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.

Rails Console Error

I've been trying to get my rails stack set up for the longest time, and so far I've been able to get everything running, but I get this error when I try to run the rails console:
C:/Ruby192/lib/ruby/1.9.1/psych.rb:148:in `parse': couldn't parse YAML at line 8 column 0 (Psych::SyntaxError)
from C:/Ruby192/lib/ruby/1.9.1/psych.rb:148:in `parse_stream'
from C:/Ruby192/lib/ruby/1.9.1/psych.rb:119:in `parse'
from C:/Ruby192/lib/ruby/1.9.1/psych.rb:106:in `load'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5.rc1/lib/rails/application/configuration.rb:88:in `database_configuration'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5.rc1/lib/active_record/railtie.rb:58:in `block (2 levels) in <class:Railtie>'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5.rc1/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5.rc1/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5.rc1/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5.rc1/lib/active_support/lazy_load_hooks.rb:42:in `each'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5.rc1/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5.rc1/lib/active_record/base.rb:1900:in `<top (required)>'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.5.rc1/lib/active_record/railtie.rb:32:in `block in <class:Railtie>'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5.rc1/lib/rails/railtie.rb:180:in `call'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5.rc1/lib/rails/railtie.rb:180:in `each'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5.rc1/lib/rails/railtie.rb:180:in `load_console'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5.rc1/lib/rails/application.rb:154:in `block in load_console'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5.rc1/lib/rails/application/railties.rb:11:in `each'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5.rc1/lib/rails/application/railties.rb:11:in `all'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5.rc1/lib/rails/application.rb:154:in `load_console'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5.rc1/lib/rails/commands/console.rb:26:in `start'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5.rc1/lib/rails/commands/console.rb:8:in `start'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5.rc1/lib/rails/commands.rb:23:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I saw various fixes online, but they didn't end up solving the problem. Just wondering if anyone else has this same issue or knows how to fix it. Thanks.
Database.yml:
# SQLite version 3.x
# gem install sqlite3
development:
adapter: mysql
database: shovell_development
pool: 5
timeout: 5000
username: root
password: randompassword12
host: localhost
# 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: mysql
database: shovell_test
pool: 5
timeout: 5000
username: root
password: randompassword12
host: localhost
production:
adapter: mysql
database: shovell_production
pool: 5
timeout: 5000
username: root
password: randompassword12
host: localhost
The problem is with the formatting of your database.yml file. The lines under timeout: 5000 should not be indended, ie:
development:
adapter: mysql
database: shovell_development
pool: 5
timeout: 5000
username: root
password: randompassword12
host: localhost
username, password and host are indented too much. They should be indented the same as the other parameters under each enviroment name.
Just remove the spaces from left side of username, password and host to make it align and try.

Resources