プロジェクト

全般

プロフィール

Vote #73432

完了

Using mysql2 doesn't need mysql gem

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Database_21
対象バージョン:
-
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
21
version_id:
0
issue_org_id:
13270
author_id:
60714
assigned_to_id:
0
comments:
17
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

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, #, 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.


journals

/mysql/ is regexp. "mysql" and "mysql2" are matched.
--------------------------------------------------------------------------------
Toshi MARUYAMA wrote:
> /mysql/ is regexp. "mysql" and "mysql2" are matched.

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

<pre>
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
</pre>

In the gem file also only mysql2 was pulled in.
--------------------------------------------------------------------------------
<pre><code class="ruby">
['mysql2', 'mysql'].each do |adapter|
case adapter
when /mysql/
puts adapter
end
end
</code></pre>

<pre>
$ ruby test.rb
mysql2
mysql
</pre>

--------------------------------------------------------------------------------
fix typo.
--------------------------------------------------------------------------------
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?

--------------------------------------------------------------------------------
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.

--------------------------------------------------------------------------------
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').

--------------------------------------------------------------------------------
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...
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------
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.

--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------
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@?

--------------------------------------------------------------------------------
This should be fixed in r11494. gem "mysql" is no longer called when using the mysql2 adapter.
--------------------------------------------------------------------------------
thankyou
--------------------------------------------------------------------------------
Why change?

Excerpt of AR-JDBC adapter Readme:

<pre>
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
</pre>

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

--------------------------------------------------------------------------------
The 'jdbc' prefix is not required, you can just set @adapter: mysql@.
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------

Admin Redmine さんが約4年前に更新

  • カテゴリDatabase_21 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0