Project

General

Profile

Actions

Defect #13270

closed

Using mysql2 doesn't need mysql gem

Added by Daniel Black over 11 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Database
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

Doing a install wanted mysql even though all database.yml entries were mysql2.

version r11458

About your application's environment
Ruby version              1.9.3 (x86_64-linux)
RubyGems version          1.8.25
Rack version              1.4
Rails version             3.2.12
Active Record version     3.2.12
Action Pack version       3.2.12
Active Resource version   3.2.12
Action Mailer version     3.2.12
Active Support version    3.2.12
Middleware                Rack::Cache, ActionDispatch::Static, Rack::Lock, #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x00000003b09818>, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::RemoteIp, ActionDispatch::Callbacks, ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, ActionDispatch::Head, Rack::ConditionalGet, Rack::ETag, ActionDispatch::BestStandardsSupport, OpenIdAuthentication
Application root          /usr/local/redmine-new/redmine-2.2-git
Environment               production
Database adapter          mysql2
Database schema version   20121026003537
--- a/Gemfile
+++ b/Gemfile
@@ -44,9 +44,10 @@ if File.exist?(database_file)
   if adapters.any?
     adapters.each do |adapter|
       case adapter
+      when /mysql2/
+        gem "mysql2", "~> 0.3.11", :platforms => [:mri_19, :mingw_19]
       when /mysql/
         gem "mysql", "~> 2.8.1", :platforms => [:mri_18, :mingw_18]
-        gem "mysql2", "~> 0.3.11", :platforms => [:mri_19, :mingw_19]
         gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
       when /postgresql/
         gem "pg", ">= 0.11.0", :platforms => [:mri, :mingw]

don't know if jruby activerecord-jdbcmysql-adapter is needed/available on mysql2.

Actions #1

Updated by Toshi MARUYAMA over 11 years ago

/mysql/ is regexp. "mysql" and "mysql2" are matched.

Actions #2

Updated by Daniel Black over 11 years ago

Toshi MARUYAMA wrote:

/mysql/ is regexp. "mysql" and "mysql2" are matched.

yes. However only the first is matched. in irb:

irb(main):007:0> case 'mysql2'
irb(main):008:1> when /mysql2/
irb(main):009:1> puts 'mysql2'
irb(main):010:1> when /mysql/
irb(main):011:1> puts 'mysql'
irb(main):012:1> end
mysql2
=> nil

In the gem file also only mysql2 was pulled in.

Actions #3

Updated by Toshi MARUYAMA over 11 years ago

['mysql2', 'mysql'].each do |adapter|
  case adapter
  when /mysql/
    puts adapter
  end
end
$ ruby test.rb
mysql2
mysql
Actions #4

Updated by Toshi MARUYAMA over 11 years ago

  • Description updated (diff)

fix typo.

Actions #5

Updated by Etienne Massip over 11 years ago

  • Status changed from New to Closed

Daniel Black wrote:

Doing a install wanted mysql even though all database.yml entries were mysql2.

This does not make sense, why would you require mysql in deps if you only set up mysql2 adapter in your database configuration?

Actions #6

Updated by Daniel Black over 11 years ago

  • Status changed from Closed to Reopened

Etienne Massip wrote:

Daniel Black wrote:

Doing a install wanted mysql even though all database.yml entries were mysql2.

This does not make sense, why would you require mysql in deps if you only set up mysql2 adapter in your database configuration?

I didn't want mysql there, the Gemfile wanted it installed. I agree it doesn't make sense and hence the whole point of this bug report and the patch to try to fix it. Maybe /mysql^/ is needed in my first in line patch instead of /mysql/. I just haven't had a chance to test this yet.

Actions #7

Updated by Etienne Massip over 11 years ago

Daniel Black wrote:

I didn't want mysql there, the Gemfile wanted it installed.

Ok, got it. It installed mysql because you are running ruby 1.8 but you want mysql2. Just curious, why would you need mysql2 with 1.8?

Maybe /mysql^/ is needed in my first in line patch instead of /mysql/. I just haven't had a chance to test this yet.

Yes, or don't use regex ('mysql').

Actions #8

Updated by Mischa The Evil over 11 years ago

Etienne Massip wrote:

Daniel Black wrote:

I didn't want mysql there, the Gemfile wanted it installed.

Ok, got it. It installed mysql because you are running ruby 1.8 but you want mysql2. Just curious, why would you need mysql2 with 1.8?

Looking at the environment info provided in the description, Daniel is not running ruby 1.8. Instead he is running on ruby 1.9; hence his use of mysql2.
A question that comes up to me is whether he is running both ruby 1.8 and 1.9? That could might explain why both mysql and mysql2 gems are installed...

Actions #9

Updated by Daniel Black over 11 years ago

Mischa The Evil wrote:

Etienne Massip wrote:

Daniel Black wrote:

I didn't want mysql there, the Gemfile wanted it installed.

Ok, got it. It installed mysql because you are running ruby 1.8 but you want mysql2. Just curious, why would you need mysql2 with 1.8?

Looking at the environment info provided in the description, Daniel is not running ruby 1.8. Instead he is running on ruby 1.9; hence his use of mysql2.

yes

A question that comes up to me is whether he is running both ruby 1.8 and 1.9?

I'm faily sure the rvm environment I have has successfully isolated the ruby-1.9 instance from the system ruby-1.8 in path precedence and RUBY_VERSION and GEM_PATH. I haven't seen the code that determines :mri_18 / :mri_19. ruby18 is still in the path if that gets checked.

That could might explain why both mysql and mysql2 gems are installed...

It could. I had missed the version tags previously.

Actions #10

Updated by Toshi MARUYAMA over 11 years ago

Simple question: Why do you want to install mysql adapter on Ruby 1.9?
There are many trouble feedback of mysql adapter on Ruby 1.9 about character encoding.

Actions #11

Updated by Daniel Black over 11 years ago

Toshi MARUYAMA wrote:

Simple question: Why do you want to install mysql adapter on Ruby 1.9?

Etienne already asked in comment 5. I answered in comment 6. I don't want mysql adapter installed and have configured mysql2 already (initial bug report) and would rather it didn't install mysql adapter. I'll be more verbose about my intent and expectations in future bug reports, particularly the ones I actually care about like #13287.

Thanks for your fixes in r11489 and r11490. That should be quite sufficient even if it doesn't quite automaticly detect which of the Ruby versions I have installed is really being used. Its really not worth spending too much time fixing this relatively minor issue.

There are many trouble feedback of mysql adapter on Ruby 1.9 about character encoding.

good to know.

Actions #12

Updated by Etienne Massip over 11 years ago

Daniel Black wrote:

Toshi MARUYAMA wrote:

Simple question: Why do you want to install mysql adapter on Ruby 1.9?

Etienne already asked in comment 5.

Actually I asked for the opposite question (but it's quite the same in the end): why do you want to install mysql2 adapter on Ruby 1.8?

Thanks for your fixes in r11489 and r11490.

These commits are unrelated, they're about minimal support of Ruby 2.0.

I don't want mysql adapter installed and have configured mysql2 already (initial bug report) and would rather it didn't install mysql adapter

I personnally understood that you wrote the exact opposite with Doing a install wanted mysql even though all database.yml entries were mysql2. :|

Its really not worth spending too much time fixing this relatively minor issue.

There's no issue from our POV: with Ruby 1.8 it will install mysql and with 1.9, mysql2.

Sorry if I repeat myself or what others already said, but are you sure it installed mysql gem with Ruby 1.9?

Actions #13

Updated by Jean-Philippe Lang over 11 years ago

  • Tracker changed from Patch to Defect
  • Subject changed from using mysql2 doesn't need mysql gem to Using mysql2 doesn't need mysql gem
  • Status changed from Reopened to Closed
  • Resolution set to Fixed

This should be fixed in r11494. gem "mysql" is no longer called when using the mysql2 adapter.

Actions #14

Updated by Daniel Black over 11 years ago

thankyou

Actions #15

Updated by Etienne Massip over 11 years ago

  • Status changed from Closed to Reopened

Why change?

Excerpt of AR-JDBC adapter Readme:

Configure your database.yml in the normal Rails style.
Legacy configuration: If you use one of the convenience activerecord-jdbcXXX-adapter adapters, you can still put a 'jdbc' prefix in front of the database adapter name e.g. :

development:
  adapter: jdbcmysql
  username: blog
  password:
  host: localhost
  database: weblog_development

We can't use jdbcmysql name anymore with r11494 but activerecord-jdbcmysql-adapter is a dependency in Gemfile?

Actions #16

Updated by Jean-Philippe Lang over 11 years ago

The 'jdbc' prefix is not required, you can just set adapter: mysql.

Actions #17

Updated by Go MAEDA over 6 years ago

  • Status changed from Reopened to Closed

Jean-Philippe Lang wrote:

The 'jdbc' prefix is not required, you can just set adapter: mysql.

And current versions of Redmine don't support jruby any longer.

Actions

Also available in: Atom PDF