Atualizando o Redmine, o ativerecord-mysql2-adapter não está funcionando

1

Para atualizar o Redmine de 1.0.1 para 2.1.2, eu preciso executar o comando: rake db:migrate RAILS_ENV=production

No entanto, isso gera o seguinte erro: rake aborted! Please install the mysql2 adapter: gem install activerecord-mysql2-adapter (mysql2 is not part of the bundle. Add it to Gemfile.)

Eu executei gem install activerecord-mysql2-adapter , mas ainda recebo o mesmo erro quando tento executar o comando rake ... .

Como faço para que meu aplicativo RoR reconheça que já tenho o adaptador mysql2 instalado? ou Há algo errado com minha instalação do ativerecord-mysql2-adapter?

Resultados de 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

Resultados de 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

Conteúdo de /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

Conteúdo de /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

Resultados de 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)

Resultados de 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)
    
por David Kaczynski 14.11.2012 / 21:03

3 respostas

3

Como você pode ver no Gemfile , o Redmine usa duas gemas diferentes do adaptador MySQL, dependendo da versão do ruby. Com o Ruby 1.8, ele usa a mysql gem, com o Ruby 1.9, a mysql2 gem.

Essas duas gemas precisam ser configuradas de forma ligeiramente diferente no database.yml , pois o nome adapter é o mesmo que o gemname. No seu caso, você precisa configurar o adapter como mysql no seu database.yml .

Se você configurar o adaptador incorreto (ou seja, um que não esteja disponível), você receberá a mensagem de erro frequentemente enganosa para instalar o activerecord-<configured adapter name>-adapter gem, que na verdade é chamado de outra coisa na maioria das vezes.

    
por 15.11.2012 / 08:01
0

A execução de bundle install no diretório raiz do Redmine provavelmente resolverá isso. Mas o que eu não vejo em sua postagem é qual versão do Redmine você está usando e para qual versão você está atualizando. Em caso de dúvida, siga o link e também link ao fazer uma atualização de versão principal.

    
por 14.11.2012 / 22:19
0

Depois de passar uma noite inteira sobre isso, fazer as seguintes alterações no Gemfile funcionou para mim:

# 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

Em seguida, execute

bundle update
    
por 22.11.2012 / 01:49