Configure database using an URL with mysql protocol, with something like this in database.yml
development:
url: mysql://user:password@localhost/app_development
adapter: mysql2
The application should load
Instead it crashes with
/home/synapse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.rc2/lib/active_support/dependencies.rb:293:in `require': Could not load 'active_record/connection_adapters/mysql_adapter'. Make sure that the adapter in config/database.yml is valid. If you use an adapter other than 'mysql2', 'postgresql' or 'sqlite3' add the necessary adapter gem to the Gemfile. (LoadError)
from /home/synapse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.rc2/lib/active_support/dependencies.rb:293:in `block in require'
from /home/synapse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.rc2/lib/active_support/dependencies.rb:259:in `load_dependency'
from /home/synapse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.rc2/lib/active_support/dependencies.rb:293:in `require'
from /home/synapse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.rc2/lib/active_record/connection_adapters/connection_specification.rb:174:in `spec'
from /home/synapse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.rc2/lib/active_record/connection_handling.rb:53:in `establish_connection'
from /home/synapse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.rc2/lib/active_record/railtie.rb:125:in `block (2 levels) in <class:Railtie>'
from /home/synapse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.rc2/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
from /home/synapse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.rc2/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
from /home/synapse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.rc2/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
from /home/synapse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.rc2/lib/active_support/lazy_load_hooks.rb:44:in `each'
from /home/synapse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.rc2/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
from /home/synapse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.rc2/lib/active_record/base.rb:324:in `<module:ActiveRecord>'
from /home/synapse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.rc2/lib/active_record/base.rb:24:in `<top (required)>'
from /home/synapse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.rc2/lib/active_support/dependencies.rb:293:in `require'
from /home/synapse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.rc2/lib/active_support/dependencies.rb:293:in `block in require'
from /home/synapse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.rc2/lib/active_support/dependencies.rb:259:in `load_dependency'
from /home/synapse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.rc2/lib/active_support/dependencies.rb:293:in `require'
from /home/synapse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/spring-1.7.1/lib/spring/application.rb:338:in `active_record_configured?'
from /home/synapse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/spring-1.7.1/lib/spring/application.rb:259:in `disconnect_database'
from /home/synapse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/spring-1.7.1/lib/spring/application.rb:97:in `preload'
from /home/synapse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/spring-1.7.1/lib/spring/application.rb:143:in `serve'
from /home/synapse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/spring-1.7.1/lib/spring/application.rb:131:in `block in run'
from /home/synapse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/spring-1.7.1/lib/spring/application.rb:125:in `loop'
from /home/synapse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/spring-1.7.1/lib/spring/application.rb:125:in `run'
from /home/synapse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/spring-1.7.1/lib/spring/application/boot.rb:19:in `<top (required)>'
from /home/synapse/.rbenv/versions/2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/synapse/.rbenv/versions/2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'
As far as I understand, Rails tries to guess adapter name from protocol, and guesses wrong. Everything works fine when protocol is changed to mysql2
Rails 5.0.0.rc2
Ruby 2.3.0
This is expected behaviour. We've removed the mysql adapter from core, but it would be dangerous to simultaneously alias it to mysql2, which has some observable differences.
Existing applications that are using URLs and intend to use mysql2 should already be using mysql2: in the protocol; they will continue to work. Applications that are currently using mysql: should be forced to choose between using a third-party copy of the old mysql adapter, or consciously switch to mysql2.
Most helpful comment
This is expected behaviour. We've removed the
mysqladapter from core, but it would be dangerous to simultaneously alias it tomysql2, which has some observable differences.Existing applications that are using URLs and intend to use
mysql2should already be usingmysql2:in the protocol; they will continue to work. Applications that are currently usingmysql:should be forced to choose between using a third-party copy of the oldmysqladapter, or consciously switch tomysql2.