Ruby on Rails cannot connect to mysql database - mysql

I have mysql installed via homebrew. Created the database prestamoApp_development I started the server (mysql.server start) and then created a new empty project (rails new prestamoApp -d mysql).
Finally configured the user and password in the database.yml file like this:
default: &default
adapter: mysql2
encoding: utf8
pool: 5
username: root
password: pqdsimple
socket: /tmp/mysql.sock
development:
<<: *default
database: prestamoApp_development
# 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: prestamoApp_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="mysql2://myuser:mypass#localhost/somedatabase"
#
# You can use this database configuration with:
#
# production:
# url: <%= ENV['DATABASE_URL'] %>
#
production:
<<: *default
database: prestamoApp_production
username: prestamoApp
password: <%= ENV['PRESTAMOAPP_DATABASE_PASSWORD'] %>
this is the gem file:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.4'
# Use mysql as the database for Active Record
gem 'mysql2'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
and just in case the gem file.lock:
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.2.4)
actionpack (= 4.2.4)
actionview (= 4.2.4)
activejob (= 4.2.4)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.4)
actionview (= 4.2.4)
activesupport (= 4.2.4)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.4)
activesupport (= 4.2.4)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
activejob (4.2.4)
activesupport (= 4.2.4)
globalid (>= 0.3.0)
activemodel (4.2.4)
activesupport (= 4.2.4)
builder (~> 3.1)
activerecord (4.2.4)
activemodel (= 4.2.4)
activesupport (= 4.2.4)
arel (~> 6.0)
activesupport (4.2.4)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
arel (6.0.3)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
builder (3.2.2)
byebug (6.0.2)
coffee-rails (4.1.0)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.9.1.1)
debug_inspector (0.0.2)
erubis (2.7.0)
execjs (2.6.0)
globalid (0.3.6)
activesupport (>= 4.1.0)
i18n (0.7.0)
jbuilder (2.3.1)
activesupport (>= 3.0.0, < 5)
multi_json (~> 1.2)
jquery-rails (4.0.5)
rails-dom-testing (~> 1.0)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (1.8.3)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.3)
mime-types (>= 1.16, < 3)
mime-types (2.6.1)
mini_portile (0.6.2)
minitest (5.8.0)
multi_json (1.11.2)
mysql2 (0.4.0)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
rack (1.6.4)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.4)
actionmailer (= 4.2.4)
actionpack (= 4.2.4)
actionview (= 4.2.4)
activejob (= 4.2.4)
activemodel (= 4.2.4)
activerecord (= 4.2.4)
activesupport (= 4.2.4)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.4)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.7)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.2)
loofah (~> 2.0)
railties (4.2.4)
actionpack (= 4.2.4)
activesupport (= 4.2.4)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.4.2)
rdoc (4.2.0)
sass (3.4.18)
sass-rails (5.0.4)
railties (>= 4.0.0, < 5.0)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
sdoc (0.4.1)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
spring (1.3.6)
sprockets (3.3.4)
rack (~> 1.0)
sprockets-rails (2.3.3)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
thor (0.19.1)
thread_safe (0.3.5)
tilt (2.0.1)
turbolinks (2.5.3)
coffee-rails
tzinfo (1.2.2)
thread_safe (~> 0.1)
uglifier (2.7.2)
execjs (>= 0.3.0)
json (>= 1.8.0)
web-console (2.2.1)
activemodel (>= 4.0)
binding_of_caller (>= 0.7.2)
railties (>= 4.0)
sprockets-rails (>= 2.0, < 4.0)
PLATFORMS
ruby
DEPENDENCIES
byebug
coffee-rails (~> 4.1.0)
jbuilder (~> 2.0)
jquery-rails
mysql2
rails (= 4.2.4)
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
spring
turbolinks
uglifier (>= 1.3.0)
web-console (~> 2.0)
BUNDLED WITH
1.10.6
When I try to do this:
rake db:schema:dump
I get this error:
rake aborted!
Gem::LoadError: Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:177:in `rescue in spec'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:174:in `spec'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_handling.rb:50:in `establish_connection'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/railtie.rb:120:in `block (2 levels) in <class:Railtie>'
/usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
/usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
/usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
/usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:44:in `each'
/usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/base.rb:315:in `<module:ActiveRecord>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/base.rb:26:in `<top (required)>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/mysql_database_tasks.rb:8:in `<class:MySQLDatabaseTasks>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/mysql_database_tasks.rb:3:in `<module:Tasks>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/mysql_database_tasks.rb:2:in `<module:ActiveRecord>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/mysql_database_tasks.rb:1:in `<top (required)>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/database_tasks.rb:50:in `<module:DatabaseTasks>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/database_tasks.rb:37:in `<module:Tasks>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/database_tasks.rb:4:in `<module:ActiveRecord>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/database_tasks.rb:3:in `<top (required)>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/railtie.rb:41:in `block (3 levels) in <class:Railtie>'
Gem::LoadError: can't activate mysql2 (~> 0.3.13), already activated mysql2-0.4.0. Make sure all dependencies are added to Gemfile.
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/rubygems_integration.rb:302:in `block in replace_gem'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/mysql2_adapter.rb:3:in `<top (required)>'
/usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `require'
/usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `block in require'
/usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:240:in `load_dependency'
/usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `require'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:175:in `spec'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_handling.rb:50:in `establish_connection'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/railtie.rb:120:in `block (2 levels) in <class:Railtie>'
/usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
/usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
/usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
/usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:44:in `each'
/usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/base.rb:315:in `<module:ActiveRecord>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/base.rb:26:in `<top (required)>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/mysql_database_tasks.rb:8:in `<class:MySQLDatabaseTasks>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/mysql_database_tasks.rb:3:in `<module:Tasks>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/mysql_database_tasks.rb:2:in `<module:ActiveRecord>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/mysql_database_tasks.rb:1:in `<top (required)>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/database_tasks.rb:50:in `<module:DatabaseTasks>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/database_tasks.rb:37:in `<module:Tasks>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/database_tasks.rb:4:in `<module:ActiveRecord>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/tasks/database_tasks.rb:3:in `<top (required)>'
/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/railtie.rb:41:in `block (3 levels) in <class:Railtie>'
Tasks: TOP => db:schema:dump => db:load_config
(See full trace by running task with --trace)
Can somebody please tell me what is wrong? What do I need to do in order to solve this problem, I've done nothing but creating an empty project.

Just downgrade mysql gem gem 'mysql2', '~> 0.3.20'
It's a bug

For new coders (like me) gem 'mysql2', '~> 0.3.20' is NOT a command!
You will get the error "Unknown command mysql2" if you try.
vi/Edit the Gemfile and append
replace
gem 'mysql2'
with
gem 'mysql2', '~> 0.3.20'
save
then type the command:
bundle install
Then retry your rake db:________ command.

Related

rails generate model : incompatible library version error

I am new to ruby on rails and getting errors when trying to generate models.
I wrote this command on terminal :
rails generate model Book
and I got this error:
/var/lib/gems/2.3.0/gems/ffi-1.9.14/lib/ffi.rb:6:in `require': incompatible library version - /var/lib/gems/2.3.0/gems/ffi-1.9.14/lib/ffi_c.so (LoadError)
from /var/lib/gems/2.3.0/gems/ffi-1.9.14/lib/ffi.rb:6:in `rescue in <top (required)>'
from /var/lib/gems/2.3.0/gems/ffi-1.9.14/lib/ffi.rb:3:in `<top (required)>'
from /var/lib/gems/2.3.0/gems/rb-inotify-0.9.7/lib/rb-inotify/native.rb:1:in `require'
from /var/lib/gems/2.3.0/gems/rb-inotify-0.9.7/lib/rb-inotify/native.rb:1:in `<top (required)>'
from /var/lib/gems/2.3.0/gems/rb-inotify-0.9.7/lib/rb-inotify.rb:1:in `require'
from /var/lib/gems/2.3.0/gems/rb-inotify-0.9.7/lib/rb-inotify.rb:1:in `<top (required)>'
from /var/lib/gems/2.3.0/gems/listen-3.0.8/lib/listen/adapter/linux.rb:30:in `require'
from /var/lib/gems/2.3.0/gems/listen-3.0.8/lib/listen/adapter/linux.rb:30:in `_configure'
from /var/lib/gems/2.3.0/gems/listen-3.0.8/lib/listen/adapter/base.rb:45:in `block in configure'
from /var/lib/gems/2.3.0/gems/listen-3.0.8/lib/listen/adapter/base.rb:40:in `each'
from /var/lib/gems/2.3.0/gems/listen-3.0.8/lib/listen/adapter/base.rb:40:in `configure'
from /var/lib/gems/2.3.0/gems/listen-3.0.8/lib/listen/adapter/base.rb:63:in `start'
from /var/lib/gems/2.3.0/gems/listen-3.0.8/lib/listen/backend.rb:28:in `start'
from /var/lib/gems/2.3.0/gems/listen-3.0.8/lib/listen/listener.rb:67:in `block in <class:Listener>'
from /var/lib/gems/2.3.0/gems/listen-3.0.8/lib/listen/fsm.rb:120:in `instance_eval'
from /var/lib/gems/2.3.0/gems/listen-3.0.8/lib/listen/fsm.rb:120:in `call'
from /var/lib/gems/2.3.0/gems/listen-3.0.8/lib/listen/fsm.rb:91:in `transition_with_callbacks!'
from /var/lib/gems/2.3.0/gems/listen-3.0.8/lib/listen/fsm.rb:57:in `transition'
from /var/lib/gems/2.3.0/gems/listen-3.0.8/lib/listen/listener.rb:90:in `start'
from /var/lib/gems/2.3.0/gems/spring-watcher-listen-2.0.0/lib/spring/watcher/listen.rb:27:in `start'
from /var/lib/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:70:in `start_watcher'
from /var/lib/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:79:in `preload'
from /var/lib/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:143:in `serve'
from /var/lib/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:131:in `block in run'
from /var/lib/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:125:in `loop'
from /var/lib/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:125:in `run'
from /var/lib/gems/2.3.0/gems/spring-1.7.2/lib/spring/application/boot.rb:19:in `<top (required)>'
from /home/pearlstud/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/pearlstud/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'
I tried adding "therubyracer" in my gemfile and then running,
bundle install
but even this doesn't help.
My rails version is "Rails 5.0.0.1".
The content of the Gemfile is as follows:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
gem 'therubyracer'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console'
gem 'listen', '~> 3.0.5'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
The contents of Gemfile.lock is as follows:
remote: https://rubygems.org/
specs:
actioncable (5.0.0.1)
actionpack (= 5.0.0.1)
nio4r (~> 1.2)
websocket-driver (~> 0.6.1)
actionmailer (5.0.0.1)
actionpack (= 5.0.0.1)
actionview (= 5.0.0.1)
activejob (= 5.0.0.1)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.0.0.1)
actionview (= 5.0.0.1)
activesupport (= 5.0.0.1)
rack (~> 2.0)
rack-test (~> 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.0.0.1)
activesupport (= 5.0.0.1)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
activejob (5.0.0.1)
activesupport (= 5.0.0.1)
globalid (>= 0.3.6)
activemodel (5.0.0.1)
activesupport (= 5.0.0.1)
activerecord (5.0.0.1)
activemodel (= 5.0.0.1)
activesupport (= 5.0.0.1)
arel (~> 7.0)
activesupport (5.0.0.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (7.1.1)
builder (3.2.2)
byebug (9.0.5)
coffee-rails (4.2.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.2.x)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.10.0)
concurrent-ruby (1.0.2)
debug_inspector (0.0.2)
erubis (2.7.0)
execjs (2.7.0)
ffi (1.9.14)
globalid (0.3.7)
activesupport (>= 4.1.0)
i18n (0.7.0)
jbuilder (2.6.0)
activesupport (>= 3.0.0, < 5.1)
multi_json (~> 1.2)
jquery-rails (4.2.1)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
libv8 (3.16.14.15)
listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.4)
mime-types (>= 1.16, < 4)
method_source (0.8.2)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
minitest (5.9.0)
multi_json (1.12.1)
nio4r (1.2.1)
nokogiri (1.6.8)
mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7)
pkg-config (1.1.7)
puma (3.6.0)
rack (2.0.1)
rack-test (0.6.3)
rack (>= 1.0)
rails (5.0.0.1)
actioncable (= 5.0.0.1)
actionmailer (= 5.0.0.1)
actionpack (= 5.0.0.1)
actionview (= 5.0.0.1)
activejob (= 5.0.0.1)
activemodel (= 5.0.0.1)
activerecord (= 5.0.0.1)
activesupport (= 5.0.0.1)
bundler (>= 1.3.0, < 2.0)
railties (= 5.0.0.1)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.1)
activesupport (>= 4.2.0, < 6.0)
nokogiri (~> 1.6.0)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
railties (5.0.0.1)
actionpack (= 5.0.0.1)
activesupport (= 5.0.0.1)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (11.2.2)
rb-fsevent (0.9.7)
rb-inotify (0.9.7)
ffi (>= 0.5.0)
ref (2.0.0)
sass (3.4.22)
sass-rails (5.0.6)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
spring (1.7.2)
spring-watcher-listen (2.0.0)
listen (>= 2.7, < 4.0)
spring (~> 1.2)
sprockets (3.7.0)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.0)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.11)
therubyracer (0.12.2)
libv8 (~> 3.16.14.0)
ref
thor (0.19.1)
thread_safe (0.3.5)
tilt (2.0.5)
turbolinks (5.0.1)
turbolinks-source (~> 5)
turbolinks-source (5.0.0)
tzinfo (1.2.2)
thread_safe (~> 0.1)
uglifier (3.0.2)
execjs (>= 0.3.0, < 3)
web-console (3.3.1)
actionview (>= 5.0)
activemodel (>= 5.0)
debug_inspector
railties (>= 5.0)
websocket-driver (0.6.4)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
PLATFORMS
ruby
DEPENDENCIES
byebug
coffee-rails (~> 4.2)
jbuilder (~> 2.5)
jquery-rails
listen (~> 3.0.5)
puma (~> 3.0)
rails (~> 5.0.0, >= 5.0.0.1)
sass-rails (~> 5.0)
spring
spring-watcher-listen (~> 2.0.0)
sqlite3
therubyracer
turbolinks (~> 5)
tzinfo-data
uglifier (>= 1.3.0)
web-console
BUNDLED WITH
1.12.5
try gem pristine --all then rails generate model Book
This error is probably caused by an older version of the library installed in the system.
First install ffi with gem command:
gem install ffi
and then do
bundle update
I had two versions of gem installed in different paths:
/var/lib/gems
and
~/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems
so I removed the gems package corresponding to "/var/lib/gems" and reinstalled rails using rbenv and the problem was solved
Both my problem and its solution were simple: I'd failed to implement a .ruby-gemset and a .ruby-version in the project directory. (Which is to say I did a long time ago... but apparently these files weren't backed up with my project an were not carried over.)
Adding these files solved the problem instantly:
.ruby-gemset
rails5
.ruby-version
ruby-2.6.2 (or whatever your version is)
It took nothing more than that. I run rvm. Mind you your rails version and ruby version are likely different... but you can find your gemsets in their directory. It will be EXTREMELY obvious which you you need.
You can find your Ruby version with:
ruby --version
This won't help everyone I know. But I'm hoping it helps SOMEONE. (At least rvm users)

rake aborted! cannot load such file -- mysql2/mysql2 on El Capitan

I have been trying from last 2 weeks to setup my code on Mac. Previously I was using Ubuntu, it was never this difficult to setup code. I have followed almost all tutorials but no luck. Please can anyone guide me on setting up RoR on mac. After following all the tutorials I end up at mysql error only.
rake aborted!
cannot load such file -- mysql2/mysql2
/Users/sahil/Documents/work/ccprod/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `require'
/Users/sahil/Documents/work/ccprod/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `block in require'
/Users/sahil/Documents/work/ccprod/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:236:in `load_dependency'
/Users/sahil/Documents/work/ccprod/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `require'
/Users/sahil/Documents/work/ccprod/vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.14/lib/mysql2.rb:8:in `<top (required)>'
/Users/sahil/.rvm/gems/ruby-1.9.3-p551#global/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `require'
/Users/sahil/.rvm/gems/ruby-1.9.3-p551#global/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
/Users/sahil/.rvm/gems/ruby-1.9.3-p551#global/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `each'
/Users/sahil/.rvm/gems/ruby-1.9.3-p551#global/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `block in require'
/Users/sahil/.rvm/gems/ruby-1.9.3-p551#global/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `each'
/Users/sahil/.rvm/gems/ruby-1.9.3-p551#global/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `require'
/Users/sahil/.rvm/gems/ruby-1.9.3-p551#global/gems/bundler-1.10.6/lib/bundler.rb:134:in `require'
/Users/sahil/Documents/work/ccprod/config/application.rb:9:in `<top (required)>'
/Users/sahil/Documents/work/ccprod/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
Please let me know if any other information is required. MySQL installed from mysql website. Additional Details:
Server version: 5.5.46 MySQL Community Server (GPL)
Update:
Gemfile.lock file:
GIT
remote: git://github.com/acumenbrands/acts_as_slugable.git
revision: 51c739b8dc283483e8cb68be2f48f0742dadbf3d
specs:
acts_as_slugable (1.0)
activerecord (>= 3.0.0)
GIT
remote: git://github.com/paneq/calendar_date_select.git
revision: 977048211b94599fe0f08eb37a481f3d69df48f6
specs:
calendar_date_select (1.16.2)
GIT
remote: git://github.com/rails/prototype_legacy_helper.git
revision: a2cd95c3e3c1a4f7a9566efdab5ce59c886cb05f
specs:
prototype_legacy_helper (0.0.0)
GIT
remote: https://github.com/Gonzih/respond_to_parent.git
revision: e7399307d70d00951916fd5e396c919cd7bb7f77
specs:
respond_to_parent (0.0.3)
rails (~> 3.2)
GIT
remote: https://github.com/jwhitehorn/acts_as_versioned.git
revision: 44dfe632ba8c97c786cbc172a2da18a41b17f668
specs:
acts_as_versioned (3.2.1)
activerecord
GEM
remote: http://rubygems.org/
specs:
actionmailer (3.2.14)
actionpack (= 3.2.14)
mail (~> 2.5.4)
actionpack (3.2.14)
activemodel (= 3.2.14)
activesupport (= 3.2.14)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
rack (~> 1.4.5)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.2.1)
active_scaffold (3.3.3)
rails (~> 3.2.0)
activemodel (3.2.14)
activesupport (= 3.2.14)
builder (~> 3.0.0)
activerecord (3.2.14)
activemodel (= 3.2.14)
activesupport (= 3.2.14)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.14)
activemodel (= 3.2.14)
activesupport (= 3.2.14)
activesupport (3.2.14)
i18n (~> 0.6, >= 0.6.4)
multi_json (~> 1.0)
acts-as-taggable-on (3.0.0)
rails (>= 3, < 5)
addressable (2.3.5)
arel (3.0.3)
asset_sync (1.0.0)
activemodel
fog (>= 1.8.0)
atomic (1.1.14)
autoparse (0.3.3)
addressable (>= 2.3.1)
extlib (>= 0.9.15)
multi_json (>= 1.0.0)
aws-sdk (1.31.3)
json (~> 1.4)
nokogiri (>= 1.4.4)
uuidtools (~> 2.1)
axiom-types (0.1.0)
descendants_tracker (~> 0.0.3)
ice_nine (~> 0.11.0)
thread_safe (~> 0.1.3)
babosa (0.3.11)
bcrypt-ruby (3.1.2)
better_errors (1.1.0)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
builder (3.0.4)
bullet (4.7.1)
activesupport
uniform_notifier (>= 1.4.0)
canonix (0.1.1)
carrierwave (0.9.0)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
json (>= 1.7)
celluloid (0.15.2)
timers (~> 1.1.0)
chartkick (1.3.2)
chronic (0.10.2)
ckeditor (4.0.7)
mime-types
orm_adapter
climate_control (0.0.3)
activesupport (>= 3.0)
cocaine (0.5.3)
climate_control (>= 0.0.3, < 1.0)
coderay (1.1.0)
coercible (1.0.0)
descendants_tracker (~> 0.0.1)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.6.3)
commonjs (0.2.7)
connection_pool (1.2.0)
crack (0.4.1)
safe_yaml (~> 0.9.0)
daemons (1.1.9)
debug_inspector (0.0.2)
delayed_job (4.0.0)
activesupport (>= 3.0, < 4.1)
delayed_job_active_record (4.0.0)
activerecord (>= 3.0, < 4.1)
delayed_job (>= 3.0, < 4.1)
delayed_job_web (1.2.10)
activerecord (> 3.0.0)
delayed_job (> 2.0.3)
sinatra (>= 1.4.4)
descendants_tracker (0.0.3)
devise (3.2.2)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 3.2.6, < 5)
thread_safe (~> 0.1)
warden (~> 1.2.3)
devise-encryptable (0.1.2)
devise (>= 2.1.0)
dotenv (0.9.0)
dynamic_form (1.1.4)
equalizer (0.0.9)
erubis (2.7.0)
event-calendar (2.3.3)
eventmachine (1.0.3)
exception_notification (4.0.1)
actionmailer (>= 3.0.4)
activesupport (>= 3.0.4)
excon (0.31.0)
execjs (2.0.2)
extlib (0.9.16)
faraday (0.8.8)
multipart-post (~> 1.2.0)
fattr (2.2.1)
fog (1.19.0)
builder
excon (~> 0.31.0)
formatador (~> 0.2.0)
mime-types
multi_json (~> 1.0)
net-scp (~> 1.1)
net-ssh (>= 2.1.3)
nokogiri (~> 1.5)
ruby-hmac
font-awesome-rails (4.2.0.0)
railties (>= 3.2, < 5.0)
foreman (0.63.0)
dotenv (>= 0.7)
thor (>= 0.13.6)
formatador (0.2.4)
god (0.13.4)
google-api-client (0.6.4)
addressable (>= 2.3.2)
autoparse (>= 0.3.3)
extlib (>= 0.9.15)
faraday (~> 0.8.4)
jwt (>= 0.1.5)
launchy (>= 2.1.1)
multi_json (>= 1.0.0)
signet (~> 0.4.5)
uuidtools (>= 2.1.0)
grape (0.11.0)
activesupport
builder
hashie (>= 2.1.0)
multi_json (>= 1.3.2)
multi_xml (>= 0.5.2)
rack (>= 1.3.0)
rack-accept
rack-mount
virtus (>= 1.0.0)
hashie (3.4.0)
highline (1.6.20)
hike (1.2.3)
httpauth (0.2.0)
i18n (0.6.9)
ice_nine (0.11.1)
journey (1.0.4)
jquery-rails (3.0.4)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.8.1)
jwt (0.1.8)
multi_json (>= 1.5)
launchy (2.4.2)
addressable (~> 2.3)
less (2.5.1)
commonjs (~> 0.2.7)
less-rails (2.5.0)
actionpack (>= 3.1)
less (~> 2.5.0)
libv8 (3.16.14.3)
macaddr (1.6.1)
systemu (~> 2.5.0)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
memcache-client (1.8.5)
mime-types (1.25.1)
mini_magick (3.7.0)
subexec (~> 0.2.1)
mono_logger (1.1.0)
multi_json (1.8.2)
multi_xml (0.5.5)
multipart-post (1.2.0)
mysql2 (0.3.14)
net-scp (1.1.2)
net-ssh (>= 2.6.5)
net-ssh (2.8.0)
nokogiri (1.5.9)
oauth (0.4.7)
oauth2 (0.9.2)
faraday (~> 0.8)
httpauth (~> 0.2)
jwt (~> 0.1.4)
multi_json (~> 1.0)
multi_xml (~> 0.5)
rack (~> 1.2)
options (2.3.0)
fattr
orm_adapter (0.5.0)
paperclip (3.5.2)
activemodel (>= 3.0.0)
activesupport (>= 3.0.0)
cocaine (~> 0.5.3)
mime-types
polyglot (0.3.3)
pr_geohash (1.0.0)
progress_bar (1.0.0)
highline (~> 1.6.1)
options (~> 2.3.0)
prototype-rails (3.2.1)
rails (~> 3.2)
rack (1.4.5)
rack-accept (0.4.5)
rack (>= 0.4)
rack-cache (1.2)
rack (>= 0.4)
rack-mount (0.8.3)
rack (>= 1.0.0)
rack-protection (1.5.3)
rack
rack-ssl (1.3.3)
rack
rack-test (0.6.2)
rack (>= 1.0)
rails (3.2.14)
actionmailer (= 3.2.14)
actionpack (= 3.2.14)
activerecord (= 3.2.14)
activeresource (= 3.2.14)
activesupport (= 3.2.14)
bundler (~> 1.0)
railties (= 3.2.14)
rails-dev-tweaks (0.6.1)
actionpack (~> 3.1)
railties (~> 3.1)
rails_autolink (1.1.5)
rails (> 3.1)
railties (3.2.14)
actionpack (= 3.2.14)
activesupport (= 3.2.14)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (10.1.1)
rdoc (3.12.2)
json (~> 1.4)
redis (3.0.6)
redis-namespace (1.4.1)
redis (~> 3.0.4)
ref (1.0.5)
resque (1.25.2)
mono_logger (~> 1.0)
multi_json (~> 1.0)
redis-namespace (~> 1.3)
sinatra (>= 0.9.2)
vegas (~> 0.1.2)
resque-web (0.0.6)
coffee-rails
jquery-rails
resque
sass-rails
twitter-bootstrap-rails
roo (1.13.2)
nokogiri
rubyzip
spreadsheet (> 0.6.4)
rsolr (1.0.9)
builder (>= 2.1.2)
ruby-hmac (0.4.0)
ruby-ole (1.2.11.7)
ruby-saml (0.7.2)
canonix (= 0.1.1)
nokogiri
uuid (~> 2.3)
rubyzip (1.1.0)
safe_yaml (0.9.7)
sass (3.2.13)
sass-rails (3.2.6)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
sentimental (1.0.3)
sidekiq (2.17.2)
celluloid (>= 0.15.2)
connection_pool (>= 1.0.0)
json
redis (>= 3.0.6)
redis-namespace (>= 1.3.1)
signet (0.4.5)
addressable (>= 2.2.3)
faraday (~> 0.8.1)
jwt (>= 0.1.5)
multi_json (>= 1.0.0)
simple_oauth (0.2.0)
sinatra (1.4.5)
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (~> 1.3, >= 1.3.4)
spreadsheet (0.9.6)
ruby-ole (>= 1.0)
sprockets (2.2.2)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
subexec (0.2.3)
sunspot (2.1.0)
pr_geohash (~> 1.0)
rsolr (~> 1.0.7)
sunspot-queue (0.10.2)
sunspot_rails (>= 1.3.0)
sunspot_rails (2.1.0)
nokogiri
rails (>= 3)
sunspot (= 2.1.0)
sunspot_solr (2.1.0)
systemu (2.5.2)
therubyracer (0.12.1)
libv8 (~> 3.16.14.0)
ref
thin (1.6.1)
daemons (>= 1.0.9)
eventmachine (>= 1.0.0)
rack (>= 1.0.0)
thor (0.18.1)
thread_safe (0.1.3)
atomic
tilt (1.4.1)
timers (1.1.0)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
turbo-sprockets-rails3 (0.3.11)
railties (> 3.2.8, < 4.0.0)
sprockets (>= 2.2.0)
twitter-bootstrap-rails (2.2.8)
actionpack (>= 3.1)
execjs
rails (>= 3.1)
railties (>= 3.1)
tzinfo (0.3.38)
uglifier (2.4.0)
execjs (>= 0.3.0)
json (>= 1.8.0)
uniform_notifier (1.4.0)
uuid (2.3.7)
macaddr (~> 1.0)
uuidtools (2.1.4)
vegas (0.1.11)
rack (>= 1.0.0)
virtus (1.0.4)
axiom-types (~> 0.1)
coercible (~> 1.0)
descendants_tracker (~> 0.0, >= 0.0.3)
equalizer (~> 0.0, >= 0.0.9)
warden (1.2.3)
rack (>= 1.0)
webmock (1.16.1)
addressable (>= 2.2.7)
crack (>= 0.3.2)
whenever (0.9.0)
activesupport (>= 2.3.4)
chronic (>= 0.6.3)
wicked_pdf (0.11.0)
rails
will_paginate (3.0.7)
will_paginate-bootstrap (1.0.1)
will_paginate (>= 3.0.3)
wkhtmltopdf-binary (0.9.9.3)
youtube_it (2.3.2)
builder
excon
faraday (~> 0.8)
json (~> 1.8.0)
nokogiri (~> 1.5.2)
oauth (~> 0.4.4)
oauth2 (~> 0.6)
simple_oauth (>= 0.1.5)
webmock
PLATFORMS
ruby
DEPENDENCIES
active_scaffold
acts-as-taggable-on
acts_as_slugable!
acts_as_versioned!
asset_sync
aws-sdk
babosa
better_errors
binding_of_caller
bullet
calendar_date_select!
carrierwave
chartkick
ckeditor
coderay
coffee-rails
delayed_job_active_record
delayed_job_web
devise
devise-encryptable
dynamic_form
event-calendar
exception_notification
font-awesome-rails
foreman
god
google-api-client
grape
jquery-rails
less-rails
memcache-client
mini_magick
mysql2 (>= 0.3)
nokogiri (= 1.5.9)
paperclip
progress_bar
prototype-rails
prototype_legacy_helper (= 0.0.0)!
rails (= 3.2.14)
rails-dev-tweaks (~> 0.6.1)
rails_autolink
respond_to_parent!
resque
resque-web
roo
ruby-saml
sass-rails
sentimental
sidekiq
sunspot-queue
sunspot_rails
sunspot_solr
therubyracer
thin
turbo-sprockets-rails3
uglifier
whenever
wicked_pdf
will_paginate (~> 3.0)
will_paginate-bootstrap
wkhtmltopdf-binary
youtube_it
database.yml:
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install 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: db_development
pool: 5
username: root
password: xyz
socket: /var/run/mysqld/mysqld.sock
The steps which worked in Ubuntu for setting up Rails:
Installation of rvm and ruby in 12.04(Followed the link)
https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-precise-pangolin-with-rvm
the steps are:
sudo apt-get update
sudo apt-get install curl
\curl -L https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm requirements(error will occur - not to worry. Go to the link provided to install the package-----)
rvm autolibs rvm_pkg
again give -> rvm requirements
rvm install 1.9.3
rvm use 1.9.3
get the code and do inside it
bundle install
later check with rails s.. if not working. do as follows
gem uninstall -i /home/user_xyz/.rvm/gems/ruby-1.9.3-p448#global bundler
then install
gem install bundler -v1.0.22
install git
sudo apt-get install git
then
bundle install --system
then again do
bundle install
If the bundle install --system is not working
gem install bundler --pre
again give
bundle install --system
It will ask to install the mysql2
install the mysql2
sudo apt-get install mysql2 -v0.3.13
again give
bundle install --system
then install the following for the mysql error
sudo apt-get install libmysql-ruby libmysqlclient-dev
After the mysql error. nokogiri error occurs
sudo apt-get install libxslt-dev libxml2-dev
sudo gem install nokogiri
finally give
bundle install --system
install netbeans
first install java package
sudo apt-get install openjdk-7-jdk
sh netbeans-7.0.1-ml-linux.sh
Proceed as follows(Due to erros do the following)
gem uninstall bundler
bundle install
rvm #global do gem uninstall bundler
gem update bundle
bundle install --system
Error for event machine(Check the link: http://stackoverflow.com/questions/4735303/failed-to-install-gem-install-eventmachine-i-need-starling-in-my-project-fo)
sudo apt-get install build-essential
install event machine
gem install eventmachine -v '1.0.3'
bundle install --system
install mysql
sudo apt-get install mysql-server
change the password in the config/database.yml for the mysql
Solution:
Steps followed to setup Rails:
installed MySQL using brew:mysql Ver 14.14 Distrib 5.7.9, for
osx10.11 (x86_64) using EditLine wrapper. Followed the commands given onscreen after mysql installation.
installed rvm with the following steps:
\curl -L https://get.rvm.io | bash -s stable —ruby
rvm install 1.9.3
rvm use 1.9.3
rvm --default 1.9.3
installed rails, gem install rails, current version is '4.2.5'.
(mysql2 gem version (0.3.20) woking with rails 4.1.4)
(mysql2 gem version (0.4.2) woking with rails 4.2.5)
(mysql2 gem version (0.3.20) woking with rails 3.2.14)
So, now I am able to create and run new rails app, but if I run any older rails app built on Ubuntu, it keeps throwing error even though bundle install completes successfully. The error message which I get:
Gem::LoadError: Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).
The error messages keeps changing but all are related to mysql2 gem. I have deleted vendor/cache, Gemfile.lock from my older project but still no success.
This problem does ring a bell, but instead of digging out the Internet and my memory, I have just tried the following: Install the latest mysql2 of the 0.3 series (0.3.20 at time of writing), and bundle it up for the application.
The problem seems that the latest mysql2 gem version 0.4 is not compatible with Rails 3.
Your gem versions cannot be changed, and you want to have the same versions as production. To do so, you could just copy over your Gemfile.lock file from the production server, put it in your local folder aside the Gemfile, and execute the bundle install command.
Note that if your Gemfile specifies:
gem 'mysql2', '> 0.3'
Then Bundler will install the latest version that matches 0.n where n >= 3. At time of writing, that leads Bundler to get a 0.4 version, which is not compatible with your Rails version (Bundler cannot infer that from your Gemfile). A workaround for you is to modify your copy of the Gemfile (and committing it to your project may be a good idea):
gem 'mysql2', '> 0.3.13' # put here the actual version used in production
Doing so, Bundler will install a version matchings 0.3.n, with n >= 13.
The first problem is that you don't have the mysql2 gem installed on your system (it seems that you've fixed this, so you don't need to worry about it).
I don't know the specifics of Mac, but in Windows, it means that you have download the appropriate libraries & get them installed on your system before installing the gem.
--
In regards the error:
Gem::LoadError: Specified 'mysql2' for database adapter, but the gem is not loaded. Add gem 'mysql2' to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).
... this problem is caused by Rails 4.2.0 - 4.2.4 calling the wrong version of mysql2: Rails 4 - Gem::LoadError: Specified 'mysql2' for database adapter, but the gem is not loaded
The solution is to change the Gemfile for any of the apps which are broken, to update them to the latest version of Rails, preferably using the 4-2-stable branch on github:
#Gemfile
gem 'rails', '~> 4.2.5', git: "git://github.com/rails/rails.git", branch: '4-2-stable'

Using Ruby and XEROUND on Heroku

First I would like to know if anyone has successfully built a Ruby on Rails application on Heroku using the XEROUND Add-on?
My PHP app works fine with the XEROUND Add-on (same database).
My Ruby application however, errors on starting.
We're sorry, but something went wrong.
On my development machine, When I run:
rails server -e production
the program starts with no problem.
When I push the code to Heroku and start the app
I get the Were sorry error.
Any ideas?
Is there anyway to output the database variables, right after they are assigned? As far as I know this would mean modifying the active-record adapter.
Is this a problem with Ruby itself? Should it have even gotten into the connection pool?
Would I be better off using XEROUND outside of Heroku (not as an Add-on)?
My database.yml contains
production:
adapter: mysql2
encoding: utf8
database: <%= ENV['XEROUND_DATABASE_NAME'] %>
username: <%= ENV['XEROUND_DATABASE_USERNAME'] %>
password: <%= ENV['XEROUND_DATABASE_PASSWORD'] %>
host: <%= ENV['XEROUND_DATABASE_HOST'] %>
port: <%= ENV['XEROUND_DATABASE_PORT'] %>
I get the same message when I hardcode the values.
Build information on Heroku:
git push heroku master
Counting objects: 15, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (10/10), done.
Writing objects: 100% (10/10), 1.19 KiB, done.
Total 10 (delta 7), reused 0 (delta 0)
-----> Heroku receiving push
-----> Ruby/Rails app detected
-----> Installing dependencies using Bundler version 1.2.1
Running: bundle install --without development:test --path vendor/bundle - -binstubs bin/
Fetching gem metadata from ....rubygems.org/.........
Using rake (0.9.2.2)
Using i18n (0.6.1)
Using multi_json (1.3.6)
Using activesupport (3.2.1)
Using builder (3.0.3)
Using activemodel (3.2.1)
Using erubis (2.7.0)
Using journey (1.0.4)
Using rack (1.4.1)
Using rack-cache (1.2)
Using rack-test (0.6.2)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.1.3)
Using actionpack (3.2.1)
Using mime-types (1.19)
Using polyglot (0.3.3)
Using treetop (1.4.10)
Using mail (2.4.4)
Using actionmailer (3.2.1)
Using arel (3.0.2)
Using tzinfo (0.3.33)
Using activerecord (3.2.1)
Using mysql2 (0.3.11)
Using activerecord-mysql2-adapter (0.0.3)
Using activeresource (3.2.1)
Using bundler (1.2.1)
Using coffee-script-source (1.3.3)
Using execjs (1.4.0)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.2)
Using json (1.7.5)
Using rdoc (3.12)
Using thor (0.14.6)
Using railties (3.2.1)
Using coffee-rails (3.2.2)
Using jquery-rails (2.1.3)
Using rails (3.2.1)
Using sass (3.2.1)
Using sass-rails (3.2.5)
Using uglifier (1.3.0)
Your bundle is complete! It was installed into ./vendor/bundle
Cleaning up the bundler cache.
-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
Detected manifest.yml, assuming assets were compiled locally
-----> Rails plugin injection
Injecting rails_log_stdout
Injecting rails3_serve_static_assets
-----> Discovering process types
Procfile declares types -> (none)
Default types for Ruby/Rails -> console, rake, web, worker
-----> Compiled slug size: 8.7MB
-----> Launching... done, v18
....shielded-brushlands-3293.herokuapp.com deployed to Heroku
To git#heroku.com:shielded-brushlands-3293.git
73c5cb6..c391a47 master -> master
The Heroku log shows:
2012-09-30T00:58:10+00:00 app[web.1]: => Booting WEBrick
2012-09-30T00:58:10+00:00 app[web.1]: => Rails 3.2.1 application starting in production on ...0.0.0.0:6832
2012-09-30T00:58:10+00:00 app[web.1]: => Call with -d to detach
2012-09-30T00:58:10+00:00 app[web.1]: => Ctrl-C to shutdown server
2012-09-30T00:58:10+00:00 app[web.1]: Started GET "/" for 76.87.97.210 at 2012-09-30 00:58:10 +0000
2012-09-30T00:58:15+00:00 heroku[router]: GET shielded-brushlands-3293.herokuapp.com/ dyno=web.1 queue=0 wait=0ms service=4529ms status=500 bytes=643
2012-09-30T00:58:15+00:00 app[web.1]: ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished):
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/connection_adapters/abstract/connection_specification.rb:142:in `connection'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/rack/logger.rb:26:in `call_app'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:66:in `call!'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/rack/logger.rb:16:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/lock.rb:15:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/rack/log_tailer.rb:14:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/request_id.rb:22:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/static.rb:53:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:136:in `forward'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/handler/webrick.rb:59:in `service'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/runtime.rb:17:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:245:in `fetch'
2012-09-30T00:58:15+00:00 app[web.1]: /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
2012-09-30T00:58:15+00:00 app[web.1]:
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/engine.rb:479:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/query_cache.rb:67:in `rescue in call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:374:in `retrieve_connection'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/content_length.rb:14:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:185:in `lookup'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/application.rb:220:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: cache: [GET /] miss
2012-09-30T00:58:15+00:00 app[web.1]:
2012-09-30T00:58:15+00:00 app[web.1]:
2012-09-30T00:58:15+00:00 app[web.1]: /usr/local/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/connection_adapters/abstract/connection_specification.rb:168:in `retrieve_connection'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/query_cache.rb:61:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:443:in `call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:405:in `_run__2306900267479677068__call__3522025195442796026__callbacks'
2012-09-30T00:58:15+00:00 app[web.1]: vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:405:in `__run_callback'
2012-09-30T00:58:15+00:00 heroku[router]: GET shielded-brushlands-3293.herokuapp.com/favicon.ico dyno=web.1 queue=0 wait=0ms service=17ms status=200 bytes=0
2012-09-30T00:58:15+00:00 app[web.1]: cache: [GET /favicon.ico] miss, store
The gemfile.lock
GEM
remote: ....rubygems.org/
specs:
actionmailer (3.2.1)
actionpack (= 3.2.1)
mail (~> 2.4.0)
actionpack (3.2.1)
activemodel (= 3.2.1)
activesupport (= 3.2.1)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.1)
rack (~> 1.4.0)
rack-cache (~> 1.1)
rack-test (~> 0.6.1)
sprockets (~> 2.1.2)
activemodel (3.2.1)
activesupport (= 3.2.1)
builder (~> 3.0.0)
activerecord (3.2.1)
activemodel (= 3.2.1)
activesupport (= 3.2.1)
arel (~> 3.0.0)
tzinfo (~> 0.3.29)
activerecord-mysql2-adapter (0.0.3)
mysql2
activeresource (3.2.1)
activemodel (= 3.2.1)
activesupport (= 3.2.1)
activesupport (3.2.1)
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.2)
builder (3.0.0)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.3.3)
erubis (2.7.0)
execjs (1.4.0)
multi_json (~> 1.0)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.4)
jquery-rails (2.1.1)
railties (>= 3.1.0, < 5.0)
thor (~> 0.14)
json (1.7.5)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.19)
multi_json (1.3.6)
mysql2 (0.3.11)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack (>= 0.4)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.2.1)
actionmailer (= 3.2.1)
actionpack (= 3.2.1)
activerecord (= 3.2.1)
activeresource (= 3.2.1)
activesupport (= 3.2.1)
bundler (~> 1.0)
railties (= 3.2.1)
railties (3.2.1)
actionpack (= 3.2.1)
activesupport (= 3.2.1)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
sass (3.2.1)
sass-rails (3.2.5)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
sprockets (2.1.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.33)
uglifier (1.2.7)
execjs (>= 0.3.0)
multi_json (~> 1.3)
PLATFORMS
ruby
DEPENDENCIES
activerecord-mysql2-adapter
coffee-rails (~> 3.2.1)
jquery-rails
mysql2
rails (= 3.2.1)
sass-rails (~> 3.2.3)
uglifier (>= 1.0.3)
I did an internet search on: xeround heroku ruby
The first item on the list:
https://devcenter.heroku.com/articles/xeround
So if I can use heroku config to set variables, then I should be able to see all variables
Next search on: heroku config
The first item on the list:
https://devcenter.heroku.com/articles/config-vars
In the config-vars article (from 2nd search) I can issue the command: heroku config
heroku config
! autoupdate in progress
=== shielded-brushlands-3293 Config Vars
DATABASE_URL: postgres://hvsosprakvuedm:v5QU211mYByXbBIdAxa3s4oMff#ec2-107-20-195-105.compute-1.amazonaws.com:5432/dehgili4ph7ih7
GEM_PATH: vendor/bundle/ruby/1.9.1
LANG: en_US.UTF-8
PATH: bin:vendor/bundle/ruby/1.9.1/bin:/usr/local/bin:/usr/bin:/bin
RACK_ENV: production
RAILS_ENV: production
XEROUND_DATABASE_ADAPTER: mysql
XEROUND_DATABASE_FAILOVER_ADAPTER: mysql
XEROUND_DATABASE_FAILOVER_HOST: instance27464.db.xeround.com.
XEROUND_DATABASE_FAILOVER_NAME: app7912272
XEROUND_DATABASE_FAILOVER_PASSWORD: xxxxx
XEROUND_DATABASE_FAILOVER_PORT: 16304
XEROUND_DATABASE_FAILOVER_URL: mysql://app7912272:xxxx#instance27464.db.xeround.com.:16304/app7912272
XEROUND_DATABASE_FAILOVER_USERNAME: app7912272
XEROUND_DATABASE_HOST: instance27464.db.xeround.com.
XEROUND_DATABASE_INTERNAL_ADAPTER: mysql
XEROUND_DATABASE_INTERNAL_HOST: int.instance27464.db.xeround.com.
XEROUND_DATABASE_INTERNAL_NAME: app7912272
XEROUND_DATABASE_INTERNAL_PASSWORD: xxxxx
XEROUND_DATABASE_INTERNAL_PORT: 16304
XEROUND_DATABASE_INTERNAL_URL: mysql://app7912272:xxxx#int.instance27464.db.xeround.com.:16304/app7912272
XEROUND_DATABASE_INTERNAL_USERNAME: app7912272
XEROUND_DATABASE_NAME: app7912272
XEROUND_DATABASE_PASSWORD: xxxxx
XEROUND_DATABASE_PORT: 16304
XEROUND_DATABASE_URL: mysql://app7912272:xxxx#instance27464.db.xeround.com.:16304/app7912272
XEROUND_DATABASE_USERNAME: app7912272
The first one caught my attention, its pointing to a postgres location.
Does it matter? I'm not referencing DATABASE_URL.
The xeround article (from 1st search) contained a line, but didn't get into why, it just said do it.
Connecting to xeround
The Xeround add-on will store the database’s URLs in two config vars:
XEROUND_DATABASE_URL and XEROUND_DATABASE_INTERNAL_URL
The “internal” URL is translated to internal IP addresses and should be used when accessing your database from within the same datacenter.
The first URL is used for connecting from outside.
Copy the value of the config variable that is relevant for you -
$ heroku config:add DATABASE_URL=(URL config vars)
Hmmm? It is not a variable I refrence in my program, nor is it set on my local machine.
Here it goes:
Since this is supposed to be a cloud database, I should not need to know anything about datacenter locations, so going with external.
heroku config:add DATABASE_URL=mysql://app7912272:xxxx#instance27464.db.xeround.com.:16304/app7912272
Setting config vars and restarting shielded-brushlands-3293... !
Autoupdate in progress
done, v20
DATABASE_URL: mysql://app7912272:XXXX#instance27464.db.xeround.com.:16304/app7912272
Lets see if it comes up....
Crap
Okay set it to internal:
heroku config:add DATABASE_URL=mysql://app7912272:xxxx#int.instance27464.db.xeround.com.:16304/app7912272
Lets see if it comes up....
Crap II
I also noticed there are two variables called XEROUND_DATABASE_ADAPTER, XEROUND_DATABASE_FAILOVER_ADAPTER and XEROUND_DATABASE_INTERNAL_ADAPTER.
They are both set to mysql.
I am using mysql2.
heroku config:add XEROUND_DATABASE_ADAPTER=mysql2
heroku config:add XEROUND_DATABASE_FAILOVER_ADAPTER=mysql2
herokU config:add XEROUND_DATABASE_INTERNAL_ADAPTER=mysql2
Lets see if it comes up....
Crap III
Further down in the article:
Each of the URLs contains a string of the following syntax:
mysql://username:password#host:port/database
The parts out of which the URLs are made of are also set for your convenience in the following environment variables:
XEROUND_DATABASE_ADAPTER
XEROUND_DATABASE_USERNAME
XEROUND_DATABASE_PASSWORD
XEROUND_DATABASE_HOST
XEROUND_DATABASE_PORT
XEROUND_DATABASE_NAME
XEROUND_DATABASE_INTERNAL_ADAPTER
XEROUND_DATABASE_INTERNAL_USERNAME
XEROUND_DATABASE_INTERNAL_PASSWORD
XEROUND_DATABASE_INTERNAL_HOST
XEROUND_DATABASE_INTERNAL_PORT
XEROUND_DATABASE_INTERNAL_NAME
Anyone who has been around programming long enough, probably knows where this is going. Sometimes you do things, even though they make no sense.
So the mysql: is derived from the adapter.
Update the url variables as well:
heroku config:add DATABASE_URL=mysql2://app7912272:xxxx#instance27464.db.xeround.com.:16304/app7912272
heroku config:add XEROUND_DATABASE_URL=mysql2://app7912272:xxxxxx#instance27464.db.xeround.com.:16304/app7912272
heroku config:add XEROUND_DATABASE_FAILOVER_URL=mysql2://app7912272:xxxxxx#instance27464.db.xeround.com.:16304/app7912272
herokU config:add XEROUND_DATABASE_INTERNAL_URL=mysql2://app7912272:xxxxxx#instance27464.db.xeround.com.:16304/app7912272
No crap, the application came up
A final look:
heroku config
! autoupdate in progress
=== shielded-brushlands-3293 Config Vars
DATABASE_URL: mysql2://app7912272:xxxx#instance27464.db.xeround.com.:16304/app7912272
GEM_PATH: vendor/bundle/ruby/1.9.1
LANG: en_US.UTF-8
PATH: bin:vendor/bundle/ruby/1.9.1/bin:/usr/local bin:/usr/bin:/bin
RACK_ENV: production
RAILS_ENV: production
XEROUND_DATABASE_ADAPTER: mysql2
XEROUND_DATABASE_FAILOVER_ADAPTER: mysql2
XEROUND_DATABASE_FAILOVER_HOST: instance27464.db.xeround.com.
XEROUND_DATABASE_FAILOVER_NAME: app7912272
XEROUND_DATABASE_FAILOVER_PASSWORD: xxxx
XEROUND_DATABASE_FAILOVER_PORT: 16304
XEROUND_DATABASE_FAILOVER_URL: mysql2://app7912272:xxxx#instance27464.db.xeround.com.:16304/app7912272
XEROUND_DATABASE_FAILOVER_USERNAME: app7912272
XEROUND_DATABASE_HOST: instance27464.db.xeround.com.
XEROUND_DATABASE_INTERNAL_ADAPTER: mysql2
XEROUND_DATABASE_INTERNAL_HOST: int.instance27464.db.xeround.com.
XEROUND_DATABASE_INTERNAL_NAME: app7912272
XEROUND_DATABASE_INTERNAL_PASSWORD: xxxx
XEROUND_DATABASE_INTERNAL_PORT: 16304
XEROUND_DATABASE_INTERNAL_URL: mysql2://app7912272:xxxx#instance27464.db.xeround.com.:16304/app7912272
XEROUND_DATABASE_INTERNAL_USERNAME: app7912272
XEROUND_DATABASE_NAME: app7912272
XEROUND_DATABASE_PASSWORD: xxxx
XEROUND_DATABASE_PORT: 16304
XEROUND_DATABASE_URL: mysql2://app7912272:xxxx#instance27464.db.xeround.com.:16304/app7912272
XEROUND_DATABASE_USERNAME: app7912272
Since the mysql2 gem is the default w/ Rails 3 all you need to do is make sure you have "gem 'mysql2'" in your gemfile, and run bundle install, commit/push to heroku
Then of course use your URL listed in heroku config under "XEROUND_DATABASE_URL"
heroku config:add DATABASE_URL=mysql2://app7912272:xxxx#instance27464.db.xeround.com.:16304/app7912272
Note the changing the mysql:// to mysql2:// (this is the key)
Then
heroku restart
I JUST did this on a brand new Rails 3.2.9 Heroku app running Xeround with success. There was no need to change the adapter to "mysql2"

"undefined method `accept' for nil:NilClass"

I am getting "undefined method `accept' for nil:NilClass" error while running db:migrate. My configuration is:
Rails 3.2.8
MySql 5.1.54
OS : win7
ruby : 1.9.2
my gems list command output:
F:\RailsApp\MyApp>gem list
*** LOCAL GEMS ***
actionmailer (3.2.8)
actionpack (3.2.8)
activemodel (3.2.8, 3.1.0)
activerecord (3.2.8)
activeresource (3.2.8)
activesupport (3.2.8, 3.1.0)
arel (3.0.2)
bcrypt-ruby (3.0.1 x86-mingw32)
builder (3.0.0)
bundler (1.1.5)
coffee-rails (3.2.2)
coffee-script (2.2.0)
coffee-script-source (1.3.3)
erubis (2.7.0)
execjs (1.4.0)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.4)
jquery-rails (2.0.2)
json (1.7.4)
mail (2.4.4)
mime-types (1.19)
minitest (1.6.0)
multi_json (1.3.6)
mysql (2.8.1 x86-mingw32)
mysql2 (0.3.11 x86-mingw32, 0.2.6 x86-mingw32)
polyglot (0.3.3)
rack (1.4.1, 1.3.6)
rack-cache (1.2)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.2.8)
railties (3.2.8)
rake (0.9.2.2, 0.8.7)
rdoc (3.12, 2.5.8)
sass (3.2.0)
sass-rails (3.2.5)
sprockets (2.1.3)
thor (0.15.4)
tilt (1.3.3)
treetop (1.4.10)
tzinfo (0.3.33)
uglifier (1.2.7)
I have also copy the %MYSQLPATH%/bin/libmySQL.dll file to %RUBYHOME%/bin folder.
Can anybody pleas help me to solve this problem?
This may be a AR-JDBC issue. Try running
bundle update activerecord-jdbc-adapter
This may help you..
If it didn't work for you, try with
bundle update mysql2
For more info look into the GitHub Issue
I had the same issue fixed by correcting database.yml file. It was having adopter as mysql2 now I have correct it to mysql
Finally I have resolve the problem with reference to this post mysql2 gem compiled for wrong mysql client library.
What I have done is as follows:
download and extract the package from http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip/from/pick
remove all mysql/mysql2 gem and re-install mysql gem with this command:
gem install mysql --platform=ruby -- --with-mysql-dir=E:/mysql-connector-c-noinstall-6.0.2-win32
add gem 'mysql' in GemFile
modify database.yml with adapter:mysql
copy MYSQLHOME/bin/libmsql.dll to RUBYHOME/bin
if find dsl error then add require 'rake/dsl_definition' at top of RakeFile
and it works.. :-)
My final GemFile is:
source 'https://rubygems.org'
gem 'rails', '3.2.3'
gem 'mysql'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'

Problem with db:migrate in rails 3.1 with mysql

I have been working with Rubymine 3.1.1 with rails 3.0.6 since last 6 months.
I have just started working with rails '3.1.0.rc5' with RubyMine 3.2.3 and mysql.
Just to get hands-on with the new version of rails, I tried creating a sample application with single scaffold (User username:string password:string), but it gives the following error on db:migrate :-
== CreateUsers: migrating ====================================================
-- create_table(:users)
rake aborted!
An error has occurred, all later migrations canceled:
undefined method `rows' for nil:NilClass
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
-> 0.1100s
== CreateUsers: migrated (0.1100s) ===========================================
Process finished with exit code 1
Any suggestions??
Thanks in advance!
==== List of gems ( Gemfile.lock ) ====
GEM
remote: http://rubygems.org/
specs:
actionmailer (3.1.0.rc5)
actionpack (= 3.1.0.rc5)
mail (~> 2.3.0)
actionpack (3.1.0.rc5)
activemodel (= 3.1.0.rc5)
activesupport (= 3.1.0.rc5)
builder (~> 3.0.0)
erubis (~> 2.7.0)
i18n (~> 0.6)
rack (~> 1.3.1)
rack-cache (~> 1.0.2)
rack-mount (~> 0.8.1)
rack-test (~> 0.6.0)
sprockets (~> 2.0.0.beta.12)
activemodel (3.1.0.rc5)
activesupport (= 3.1.0.rc5)
bcrypt-ruby (~> 2.1.4)
builder (~> 3.0.0)
i18n (~> 0.6)
activerecord (3.1.0.rc5)
activemodel (= 3.1.0.rc5)
activesupport (= 3.1.0.rc5)
arel (~> 2.1.4)
tzinfo (~> 0.3.29)
activeresource (3.1.0.rc5)
activemodel (= 3.1.0.rc5)
activesupport (= 3.1.0.rc5)
activesupport (3.1.0.rc5)
multi_json (~> 1.0)
ansi (1.3.0)
arel (2.1.4)
bcrypt-ruby (2.1.4-x86-mingw32)
builder (3.0.0)
coffee-rails (3.1.0.rc.5)
actionpack (~> 3.1.0.rc1)
coffee-script (>= 2.2.0)
railties (~> 3.1.0.rc1)
sprockets (>= 2.0.0.beta.9)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.1.2)
erubis (2.7.0)
execjs (1.2.4)
multi_json (~> 1.0)
hike (1.2.0)
i18n (0.6.0)
jquery-rails (1.0.12)
railties (~> 3.0)
thor (~> 0.14)
mail (2.3.0)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
multi_json (1.0.3)
mysql2 (0.2.6-x86-mingw32)
polyglot (0.3.2)
rack (1.3.2)
rack-cache (1.0.2)
rack (>= 0.4)
rack-mount (0.8.1)
rack (>= 1.0.0)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.1.0.rc5)
actionmailer (= 3.1.0.rc5)
actionpack (= 3.1.0.rc5)
activerecord (= 3.1.0.rc5)
activeresource (= 3.1.0.rc5)
activesupport (= 3.1.0.rc5)
bundler (~> 1.0)
railties (= 3.1.0.rc5)
railties (3.1.0.rc5)
actionpack (= 3.1.0.rc5)
activesupport (= 3.1.0.rc5)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2)
rdoc (3.9.1)
sass (3.1.7)
sass-rails (3.1.0.rc.5)
actionpack (~> 3.1.0.rc1)
railties (~> 3.1.0.rc1)
sass (>= 3.1.4)
sprockets (>= 2.0.0.beta.9)
sprockets (2.0.0.beta.13)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
thor (0.14.6)
tilt (1.3.2)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
turn (0.8.2)
ansi (>= 1.2.2)
tzinfo (0.3.29)
uglifier (1.0.0)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
PLATFORMS
x86-mingw32
DEPENDENCIES
coffee-rails (~> 3.1.0.rc)
jquery-rails
mysql2
rails (= 3.1.0.rc5)
sass-rails (~> 3.1.0.rc)
turn
uglifier
=== gem environment ===
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.9.2 (2010-08-18 patchlevel 0) [i386-mingw32]
- INSTALLATION DIRECTORY: C:/Ruby192/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: C:/Ruby192/bin/ruby.exe
- EXECUTABLE DIRECTORY: C:/Ruby192/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-mingw32
- GEM PATHS:
- C:/Ruby192/lib/ruby/gems/1.9.1
- C:/Users/rashmi/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
I'm using mac OS X Lion the solution was:
On Gemfile:
Just replace the old version of mysql for this one:
gem 'mysql2', '0.3.7'