MySQLproblem - RAILS_ENV=生产bundle exec rake db:migrate

时间:2021-07-04 23:13:21

I am just installing the redmine to my server due to detailed manual. Everything gone fine but one of the last step fail with some bug and I have no idea how to fix it.

由于详细的手册,我正在将redmine安装到我的服务器上。一切都很顺利,但最后一步中有一个错误,我不知道如何修复它。

Command is

命令

RAILS_ENV=production bundle exec rake db:migrate

Output error

输出误差

You cannot specify the same gem twice with different version requirements. 
You specified: mysql (>= 0) and mysql (~> 2.9.1)

gem list

宝石列表

*** LOCAL GEMS ***

actionmailer (3.2.15)
actionpack (3.2.15)
activemodel (3.2.15)
activerecord (3.2.15)
activeresource (3.2.15)
activesupport (3.2.15)
arel (3.0.3)
bigdecimal (1.2.0)
builder (3.0.0)
bundler (1.3.5)
capybara (2.1.0)
childprocess (0.3.9)
coderay (1.1.0)
daemon_controller (1.1.7)
database_cleaner (1.2.0)
erubis (2.7.0)
ffi (1.9.3)
hike (1.2.3)
hoe (3.7.1)
i18n (0.6.4)
io-console (0.4.2)
journey (1.0.4)
jquery-rails (2.0.3)
json (1.8.1, 1.7.7)
mail (2.5.4)
metaclass (0.0.1)
mime-types (1.25.1)
mini_portile (0.5.2)
minitest (4.3.2)
mocha (0.14.0)
multi_json (1.8.2)
mysql (2.9.1)
net-ldap (0.3.1)
nokogiri (1.6.0)
passenger (4.0.25)
polyglot (0.3.3)
psych (2.0.0)
rack (1.5.2, 1.4.5)
rack-cache (1.2)
rack-openid (1.4.1)
rack-ssl (1.3.3)
rack-test (0.6.2)
rails (3.2.15)
railties (3.2.15)
rake (0.9.6, 0.8.7)
rdoc (4.0.0, 3.12.2)
RedCloth (4.2.9)
rmagick (2.13.2)
ruby-openid (2.3.0)
rubygems-update (2.1.11)
rubytree (0.5.2)
rubyzip (1.0.0)
selenium-webdriver (2.37.0)
shoulda (3.3.2)
shoulda-context (1.0.2)
shoulda-matchers (1.4.1)
sprockets (2.2.2)
test-unit (2.0.0.0)
thor (0.18.1)
tilt (1.4.1)
treetop (1.4.15)
tzinfo (0.3.38)
websocket (1.0.7)
xpath (2.0.0)
yard (0.8.7.3)

Gemfile

Gemfile

    source 'https://rubygems.org'

    gem "rake", "0.8.7"
    gem "rack", "1.4.5"
    gem "i18n", "0.6.4"
    gem "rubytree", "0.5.2", :require => "tree"
    gem "RedCloth", "~>4.2.3", :require => "redcloth" # for CodeRay
    gem "mysql"

    gem "rails", "3.2.15"
    gem "jquery-rails", "~> 2.0.2"
    gem "coderay", "~> 1.1.0"
    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.3.0", :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

    platforms :jruby do
      # jruby-openssl is bundled with JRuby 1.7.0
      gem "jruby-openssl" if Object.const_defined?(:JRUBY_VERSION) && JRUBY_VERSION < '1.7.0'
      gem "activerecord-jdbc-adapter", "~> 1.3.2"
    end

    # Include database gems for the adapters found in the database
    # configuration file
    require 'erb'
    require 'yaml'
    database_file = File.join(File.dirname(__FILE__), "config/database.yml")
    if File.exist?(database_file)

   database_config = YAML::load(ERB.new(IO.read(database_file)).result)
   adapters = database_config.values.map {|c| c['adapter']}.compact.uniq
   if adapters.any?

    adapters.each do |adapter|
      case adapter
      when 'mysql2'
        gem "mysql2", "~> 0.3.11", :platforms => [:mri, :mingw]
        gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
      when 'mysql'
        gem "mysql", "~>2.9.1", :platforms => [:mri, :mingw]
        gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
      when /postgresql/
        gem "pg", ">= 0.11.0", :platforms => [:mri, :mingw]
        gem "activerecord-jdbcpostgresql-adapter", :platforms => :jruby
      when /sqlite3/
        gem "sqlite3", :platforms => [:mri, :mingw]
        gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby
      when /sqlserver/
        gem "tiny_tds", "~> 0.5.1", :platforms => [:mri, :mingw]
        gem "activerecord-sqlserver-adapter", :platforms => [:mri, :mingw]
      else
        warn("Unknown database adapter `#{adapter}` found in config/database.yml, use 

    Gemfile.local to load your own database gems")
          end
        end
      else
        warn("No adapter found in config/database.yml, please configure it first")
      end
    else
      warn("Please configure your config/database.yml first")
    end

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

    group :test do
      gem "shoulda", "~> 3.3.2"
      gem "mocha", ">= 0.14", :require => 'mocha/api'
      if RUBY_VERSION >= '1.9.3'
        gem "capybara", "~> 2.1.0"
        gem "selenium-webdriver"
        gem "database_cleaner"
      end
    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`
      #TODO: switch to "eval_gemfile file" when bundler >= 1.2.0 will be required (rails 4)
      instance_eval File.read(file), file
    end

Thank you for any answer.

谢谢你的回答。

Nice day Jan

美好的一天1

3 个解决方案

#1


1  

You seem to be including the mysql gem when you loop through the adapters in your Gemfile. You should be good to go once you remove the following line from your Gemfile:

当您循环遍历Gemfile中的适配器时,似乎包含了mysql gem。当你从你的Gemfile中移除下面一行时,你应该很好。

gem "rake", "0.8.7"
gem "rack", "1.4.5"
gem "i18n", "0.6.4"
gem "rubytree", "0.5.2", :require => "tree"
gem "RedCloth", "~>4.2.3", :require => "redcloth" # for CodeRay
gem "mysql" # <---------------- Remove this line.

#2


1  

Remove the first gem "mysql" on line 8 of your gemfile because the db gems are included automaticly based on which adapter your using. Then run bundle again and retry.

在您的gemfile第8行删除第一个gem“mysql”,因为db gems是基于您使用的适配器自动包含的。然后再次运行bundle并重试。

#3


1  

The error message is pretty clear. You have the mysql gem in multiple places. One on top and one from the case statement

错误信息非常清晰。mysql gem存在于多个地方。一个在上面,一个来自case语句

#1


1  

You seem to be including the mysql gem when you loop through the adapters in your Gemfile. You should be good to go once you remove the following line from your Gemfile:

当您循环遍历Gemfile中的适配器时,似乎包含了mysql gem。当你从你的Gemfile中移除下面一行时,你应该很好。

gem "rake", "0.8.7"
gem "rack", "1.4.5"
gem "i18n", "0.6.4"
gem "rubytree", "0.5.2", :require => "tree"
gem "RedCloth", "~>4.2.3", :require => "redcloth" # for CodeRay
gem "mysql" # <---------------- Remove this line.

#2


1  

Remove the first gem "mysql" on line 8 of your gemfile because the db gems are included automaticly based on which adapter your using. Then run bundle again and retry.

在您的gemfile第8行删除第一个gem“mysql”,因为db gems是基于您使用的适配器自动包含的。然后再次运行bundle并重试。

#3


1  

The error message is pretty clear. You have the mysql gem in multiple places. One on top and one from the case statement

错误信息非常清晰。mysql gem存在于多个地方。一个在上面,一个来自case语句