web-dev-qa-db-ja.com

Redmineのアップグレード、activerecord-mysql2-adapterが機能しない

Redmineを1.0.1から2.1.2にアップグレードするには、次のコマンドを実行する必要があります:_rake db:migrate Rails_ENV=production_

ただし、これを行うと、次のエラーが発生します:rake aborted! Please install the mysql2 adapter: gem install activerecord-mysql2-adapter (mysql2 is not part of the bundle. Add it to Gemfile.)

_gem install activerecord-mysql2-adapter_を実行しましたが、_rake ..._コマンドを実行しようとすると同じエラーが発生します。

RoRアプリにmysql2アダプターが既にインストールされていることを認識させるにはどうすればよいですか?またはactiverecord-mysql2-adapterのインストールに問題がありますか?


_Sudo bundle install_の結果:

_Using rake (10.0.0) 
Using i18n (0.6.1) 
Using multi_json (1.3.7) 
Using activesupport (3.2.8) 
Using builder (3.0.0) 
Using activemodel (3.2.8) 
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.8) 
Using mime-types (1.19) 
Using polyglot (0.3.3) 
Using treetop (1.4.12) 
Using mail (2.4.4) 
Using actionmailer (3.2.8) 
Using arel (3.0.2) 
Using tzinfo (0.3.35) 
Using activerecord (3.2.8) 
Using activeresource (3.2.8) 
Using coderay (1.0.8) 
Using fastercsv (1.5.5) 
Using rack-ssl (1.3.2) 
Using json (1.7.5) 
Using rdoc (3.12) 
Using thor (0.16.0) 
Using railties (3.2.8) 
Using jquery-Rails (2.0.3) 
Using metaclass (0.0.1) 
Using mocha (0.12.3) 
Using mysql (2.8.1) 
Using net-ldap (0.3.1) 
Using pg (0.14.1) 
Using Ruby-openid (2.1.8) 
Using rack-openid (1.3.1) 
Using bundler (1.2.1) 
Using Rails (3.2.8) 
Using rmagick (2.13.1) 
Using shoulda (2.11.3) 
Using sqlite3 (1.3.6) 
Using yard (0.8.3) 
[32mYour bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.[0m
_

_Sudo find / -name "*mysql2*"_の結果:

_/var/lib/gems/1.8/doc/mysql2-0.3.11
/var/lib/gems/1.8/doc/activerecord-3.2.9/ri/ActiveRecord/Base/mysql2_connection-c.ri
/var/lib/gems/1.8/doc/activerecord-mysql2-adapter-0.0.3
/var/lib/gems/1.8/doc/activerecord-mysql2-adapter-0.0.3/ri/ActiveRecord/Base/em_mysql2_connection-c.ri
/var/lib/gems/1.8/doc/activerecord-mysql2-adapter-0.0.3/ri/ActiveRecord/Base/mysql2_connection-c.ri
/var/lib/gems/1.8/gems/mysql2-0.3.11
/var/lib/gems/1.8/gems/mysql2-0.3.11/spec/mysql2
/var/lib/gems/1.8/gems/mysql2-0.3.11/mysql2.gemspec
/var/lib/gems/1.8/gems/mysql2-0.3.11/lib/mysql2.rb
/var/lib/gems/1.8/gems/mysql2-0.3.11/lib/mysql2
/var/lib/gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.so
/var/lib/gems/1.8/gems/mysql2-0.3.11/ext/mysql2
/var/lib/gems/1.8/gems/mysql2-0.3.11/ext/mysql2/mysql2.so
/var/lib/gems/1.8/gems/mysql2-0.3.11/ext/mysql2/mysql2_ext.c
/var/lib/gems/1.8/gems/mysql2-0.3.11/ext/mysql2/mysql2_ext.h
/var/lib/gems/1.8/gems/mysql2-0.3.11/ext/mysql2/mysql2_ext.o
/var/lib/gems/1.8/gems/activerecord-3.2.9/lib/active_record/connection_adapters/mysql2_adapter.rb
/var/lib/gems/1.8/gems/activerecord-mysql2-adapter-0.0.3
/var/lib/gems/1.8/gems/activerecord-mysql2-adapter-0.0.3/activerecord-mysql2-adapter.gemspec
/var/lib/gems/1.8/gems/activerecord-mysql2-adapter-0.0.3/lib/arel/engines/sql/compilers/mysql2_compiler.rb
/var/lib/gems/1.8/gems/activerecord-mysql2-adapter-0.0.3/lib/activerecord-mysql2-adapter.rb
/var/lib/gems/1.8/gems/activerecord-mysql2-adapter-0.0.3/lib/activerecord-mysql2-adapter
/var/lib/gems/1.8/gems/activerecord-mysql2-adapter-0.0.3/lib/active_record/connection_adapters/em_mysql2_adapter.rb
/var/lib/gems/1.8/gems/activerecord-mysql2-adapter-0.0.3/lib/active_record/connection_adapters/mysql2_adapter.rb
/var/lib/gems/1.8/gems/activerecord-3.2.8/lib/active_record/connection_adapters/mysql2_adapter.rb
/var/lib/gems/1.8/cache/mysql2-0.3.11.gem
/var/lib/gems/1.8/cache/activerecord-mysql2-adapter-0.0.3.gem
/var/lib/gems/1.8/specifications/activerecord-mysql2-adapter-0.0.3.gemspec
/var/lib/gems/1.8/specifications/mysql2-0.3.11.gemspec
_

_/usr/share/redmine/Gemfile_の内容:

_source 'http://rubygems.org'

gem 'Rails', '3.2.8'
gem "jquery-Rails", "~> 2.0.2"
gem "i18n", "~> 0.6.0"
gem "coderay", "~> 1.0.6"
gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby]
gem "builder", "3.0.0"

# Optional gem for LDAP authentication
group :ldap do
  gem "net-ldap", "~> 0.3.1"
end

# Optional gem for OpenID authentication
group :openid do
  gem "Ruby-openid", "~> 2.1.4", :require => "openid"
  gem "rack-openid"
end

# Optional gem for exporting the gantt to a PNG file, not supported with jruby
platforms :mri, :mingw do
  group :rmagick do
    # RMagick 2 supports Ruby 1.9
    # RMagick 1 would be fine for Ruby 1.8 but Bundler does not support
    # different requirements for the same gem on different platforms
    gem "rmagick", ">= 2.0.0"
  end
end

# Database gems
platforms :mri, :mingw do
  group :postgresql do
    gem "pg", ">= 0.11.0"
  end

  group :sqlite do
    gem "sqlite3"
  end
end

platforms :mri_18, :mingw_18 do
  group :mysql do
    gem "mysql"
  end
end

platforms :mri_19, :mingw_19 do
  group :mysql do
    gem "mysql2", "~> 0.3.11"
  end
end

platforms :jruby do
  gem "jruby-openssl"

  group :mysql do
    gem "activerecord-jdbcmysql-adapter"
  end

  group :postgresql do
    gem "activerecord-jdbcpostgresql-adapter"
  end

  group :sqlite do
    gem "activerecord-jdbcsqlite3-adapter"
  end
end

group :development do
  gem "rdoc", ">= 2.4.2"
  gem "yard"
end

group :test do
  gem "shoulda", "~> 2.11"
  # Shoulda does not work Nice on Ruby 1.9.3 and seems to need test-unit explicitely.
  gem "test-unit", :platforms => [:mri_19]
  gem "mocha", "0.12.3"
end

local_gemfile = File.join(File.dirname(__FILE__), "Gemfile.local")
if File.exists?(local_gemfile)
  puts "Loading Gemfile.local ..." if $DEBUG # `Ruby -d` or `bundle -v`
  instance_eval File.read(local_gemfile)
end

# Load plugins' Gemfiles
Dir.glob File.expand_path("../plugins/*/Gemfile", __FILE__) do |file|
  puts "Loading #{file} ..." if $DEBUG # `Ruby -d` or `bundle -v`
  instance_eval File.read(file)
end
_

_/usr/share/redmine/Gemfile.lock_の内容:

_GEM
  remote: http://rubygems.org/
  specs:
    actionmailer (3.2.8)
      actionpack (= 3.2.8)
      mail (~> 2.4.4)
    actionpack (3.2.8)
      activemodel (= 3.2.8)
      activesupport (= 3.2.8)
      builder (~> 3.0.0)
      erubis (~> 2.7.0)
      journey (~> 1.0.4)
      rack (~> 1.4.0)
      rack-cache (~> 1.2)
      rack-test (~> 0.6.1)
      sprockets (~> 2.1.3)
    activemodel (3.2.8)
      activesupport (= 3.2.8)
      builder (~> 3.0.0)
    activerecord (3.2.8)
      activemodel (= 3.2.8)
      activesupport (= 3.2.8)
      arel (~> 3.0.2)
      tzinfo (~> 0.3.29)
    activeresource (3.2.8)
      activemodel (= 3.2.8)
      activesupport (= 3.2.8)
    activesupport (3.2.8)
      i18n (~> 0.6)
      multi_json (~> 1.0)
    arel (3.0.2)
    builder (3.0.0)
    coderay (1.0.8)
    erubis (2.7.0)
    fastercsv (1.5.5)
    hike (1.2.1)
    i18n (0.6.1)
    journey (1.0.4)
    jquery-Rails (2.0.3)
      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)
    metaclass (0.0.1)
    mime-types (1.19)
    mocha (0.12.3)
      metaclass (~> 0.0.1)
    multi_json (1.3.7)
    mysql (2.8.1)
    mysql2 (0.3.11)
    net-ldap (0.3.1)
    pg (0.14.1)
    polyglot (0.3.3)
    rack (1.4.1)
    rack-cache (1.2)
      rack (>= 0.4)
    rack-openid (1.3.1)
      rack (>= 1.1.0)
      Ruby-openid (>= 2.1.8)
    rack-ssl (1.3.2)
      rack
    rack-test (0.6.2)
      rack (>= 1.0)
    Rails (3.2.8)
      actionmailer (= 3.2.8)
      actionpack (= 3.2.8)
      activerecord (= 3.2.8)
      activeresource (= 3.2.8)
      activesupport (= 3.2.8)
      bundler (~> 1.0)
      railties (= 3.2.8)
    railties (3.2.8)
      actionpack (= 3.2.8)
      activesupport (= 3.2.8)
      rack-ssl (~> 1.3.2)
      rake (>= 0.8.7)
      rdoc (~> 3.4)
      thor (>= 0.14.6, < 2.0)
    rake (10.0.0)
    rdoc (3.12)
      json (~> 1.4)
    rmagick (2.13.1)
    Ruby-openid (2.1.8)
    shoulda (2.11.3)
    sprockets (2.1.3)
      hike (~> 1.2)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    sqlite3 (1.3.6)
    test-unit (2.5.2)
    thor (0.16.0)
    tilt (1.3.3)
    treetop (1.4.12)
      polyglot
      polyglot (>= 0.3.1)
    tzinfo (0.3.35)
    yard (0.8.3)

PLATFORMS
  Ruby

DEPENDENCIES
  activerecord-jdbcmysql-adapter
  activerecord-jdbcpostgresql-adapter
  activerecord-jdbcsqlite3-adapter
  builder (= 3.0.0)
  coderay (~> 1.0.6)
  fastercsv (~> 1.5.0)
  i18n (~> 0.6.0)
  jquery-Rails (~> 2.0.2)
  jruby-openssl
  mocha (= 0.12.3)
  mysql
  mysql2 (~> 0.3.11)
  net-ldap (~> 0.3.1)
  pg (>= 0.11.0)
  rack-openid
  Rails (= 3.2.8)
  rdoc (>= 2.4.2)
  rmagick (>= 2.0.0)
  Ruby-openid (~> 2.1.4)
  shoulda (~> 2.11)
  sqlite3
  test-unit
  yard
_

_gem list_の結果:

_actionmailer (3.2.9, 3.2.8)
actionpack (3.2.9, 3.2.8)
activemodel (3.2.9, 3.2.8)
activerecord (3.2.9, 3.2.8)
activerecord-mysql2-adapter (0.0.3)
activeresource (3.2.9, 3.2.8)
activesupport (3.2.9, 3.2.8)
arel (3.0.2)
builder (3.0.0)
bundler (1.2.1)
coderay (1.0.8)
erubis (2.7.0)
fastercsv (1.5.5)
hike (1.2.1)
i18n (0.6.1)
journey (1.0.4)
jquery-Rails (2.0.3)
json (1.7.5)
mail (2.4.4)
metaclass (0.0.1)
mime-types (1.19)
mocha (0.12.3)
multi_json (1.3.7)
mysql (2.8.1)
mysql2 (0.3.11)
net-ldap (0.3.1)
pg (0.14.1)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack-openid (1.3.1)
rack-ssl (1.3.2)
rack-test (0.6.2)
Rails (3.2.9, 3.2.8)
railties (3.2.9, 3.2.8)
rake (10.0.0)
rdoc (3.12)
rmagick (2.13.1)
Ruby-openid (2.1.8)
shoulda (2.11.3)
sprockets (2.2.1, 2.1.3)
sqlite3 (1.3.6)
thor (0.16.0)
tilt (1.3.3)
treetop (1.4.12)
tzinfo (0.3.35)
yard (0.8.3)
_

_bundle show_の結果:

_Gems included by the bundle:
  * actionmailer (3.2.8)
  * actionpack (3.2.8)
  * activemodel (3.2.8)
  * activerecord (3.2.8)
  * activeresource (3.2.8)
  * activesupport (3.2.8)
  * arel (3.0.2)
  * builder (3.0.0)
  * bundler (1.2.1)
  * coderay (1.0.8)
  * erubis (2.7.0)
  * fastercsv (1.5.5)
  * hike (1.2.1)
  * i18n (0.6.1)
  * journey (1.0.4)
  * jquery-Rails (2.0.3)
  * json (1.7.5)
  * mail (2.4.4)
  * metaclass (0.0.1)
  * mime-types (1.19)
  * mocha (0.12.3)
  * multi_json (1.3.7)
  * mysql (2.8.1)
  * net-ldap (0.3.1)
  * pg (0.14.1)
  * polyglot (0.3.3)
  * rack (1.4.1)
  * rack-cache (1.2)
  * rack-openid (1.3.1)
  * rack-ssl (1.3.2)
  * rack-test (0.6.2)
  * Rails (3.2.8)
  * railties (3.2.8)
  * rake (10.0.0)
  * rdoc (3.12)
  * rmagick (2.13.1)
  * Ruby-openid (2.1.8)
  * shoulda (2.11.3)
  * sprockets (2.1.3)
  * sqlite3 (1.3.6)
  * thor (0.16.0)
  * tilt (1.3.3)
  * treetop (1.4.12)
  * tzinfo (0.3.35)
  * yard (0.8.3)
_
1
David Kaczynski

Gemfileでわかるように、RedmineはRubyバージョンに応じて2つの異なるMySQLアダプターgemを使用します。Ruby 1.8では、 mysql gem、Ruby 1.9、mysql2gem。

adapter名はgemnameと同じであるため、これら2つのgemはdatabase.ymlで少し異なる方法で構成する必要があります。あなたの場合、あなたはあなたのdatabase.ymladaptermysqlとして設定する必要があります。

間違ったアダプター(つまり、使用できないアダプター)を構成すると、activerecord-<configured adapter name>-adapter gemをインストールするために、誤解を招くエラーメッセージが表示されることがよくあります。これは、実際にはほとんどの場合、別のアダプターと呼ばれます。

3
Holger Just

これに一晩を費やした後、Gemfileに次の変更を加えることは私のために働きました:

# platforms :mri_18, :mingw_18 do
#  group :mysql do
#    gem "mysql"
#  end
# end

platforms :mri_18, :mingw_18, :mri_19, :mingw_19 do
  group :mysql do
    gem "mysql2", "~> 0.3.11"
  end
end

次に実行します

bundle update
0
Harshit

ランニング bundle installRedmineルートディレクトリでおそらくこれを解決します。しかし、あなたの投稿に表示されていないのは、使用しているRedmineのバージョンと、アップグレードしているバージョンです。疑わしい場合は、 http://www.redmine.org/projects/redmine/wiki/RedmineUpgrade および http://www.redmine.org/projects/redmine/wiki/ RedmineInstall メジャーバージョンのアップグレードを行う場合。

0
daff