我正在使用 Ruby 版本:1.8.7 和 Gem 版本:1.8.25 的 CentOS 6.3 Linux 服务器
我正在尝试运行命令:ruby script/rails server webrick -e production
它吐出这个错误:
=> Booting WEBrick
=> Rails 3.2.8 application starting in production on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/usr/lib64/ruby/gems/1.8/gems/bundler-1.2.3/lib/bundler/rubygems_integration.rb:157:in `gem': Please install the mysql adapter: `gem install activerecord-mysql-adapter` (can't activate mysql (~> 2.8.1), already activated mysql-2.9.0. Make sure all dependencies are added to Gemfile.) (LoadError)
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/connection_adapters/mysql_adapter.rb:5
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:50:in `resolve_hash_connection'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:41:in `resolve_string_connection'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:25:in `spec'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:129:in `establish_connection'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/railtie.rb:82
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:43:in `run_load_hooks'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:42:in `each'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/base.rb:721
from /var/www/redmine/lib/plugins/acts_as_activity_provider/init.rb:2
from /var/www/redmine/config/initializers/00-core_plugins.rb:12
from /var/www/redmine/config/initializers/00-core_plugins.rb:2:in `each'
from /var/www/redmine/config/initializers/00-core_plugins.rb:2
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `load'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `load'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `load'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/engine.rb:588
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/engine.rb:587:in `each'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/engine.rb:587
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `instance_exec'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `run'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/initializable.rb:55:in `run_initializers'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `each'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `run_initializers'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/application.rb:136:in `initialize!'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/railtie/configurable.rb:30:in `send'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /var/www/redmine/config/environment.rb:14
from /var/www/redmine/config.ru:4:in `require'
from /var/www/redmine/config.ru:4
from /usr/lib64/ruby/gems/1.8/gems/rack-1.4.0/lib/rack/builder.rb:51:in `instance_eval'
from /usr/lib64/ruby/gems/1.8/gems/rack-1.4.0/lib/rack/builder.rb:51:in `initialize'
from /var/www/redmine/config.ru:1:in `new'
from /var/www/redmine/config.ru:1
这是我的 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"
gem "rake", "0.8.7"
gem "rack", "1.4.0"
gem "rubytree", "0.5.2", :require => "tree"
gem "RedCloth", "~>4.2.3", :require => "redcloth" # for CodeRay
gem "mysql", "2.9.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", "2.9.0"
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
我已经安装了 activerecord-mysql-adapter - 它没有错误......
我试图更改 Gemfile 以匹配它吐出的错误,即 (~> 2.8.1) 版本,但这也不起作用......
任何帮助将不胜感激...
更新!!
我卸载了 MySQL 2.9.0 并安装了 MySQL 2.8.1 并更改了我的 Gemfile 以反映正确的版本,但现在我收到了这个错误:
=> Booting WEBrick
=> Rails 3.2.8 application starting in production on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `query': Mysql::Error: Table 'redmine.users' doesn't exist: SHOW FULL FIELDS FROM `users` (ActiveRecord::StatementInvalid)
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `execute'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `log'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `execute'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/connection_adapters/mysql_adapter.rb:324:in `execute_and_free'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:426:in `columns'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/connection_adapters/schema_cache.rb:12:in `initialize'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/model_schema.rb:228:in `call'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/model_schema.rb:228:in `default'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/model_schema.rb:228:in `[]'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/model_schema.rb:228:in `columns'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/model_schema.rb:237:in `columns_hash'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/inheritance.rb:19:in `descends_from_active_record?'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/inheritance.rb:25:in `finder_needs_type_condition?'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/base.rb:455:in `relation'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/scoping/named.rb:37:in `scoped'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/querying.rb:9:in `order'
from /var/www/redmine/app/models/group.rb:32
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:359:in `require_or_load'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:313:in `depend_on'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:225:in `require_dependency'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/engine.rb:439:in `eager_load!'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/engine.rb:438:in `each'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/engine.rb:438:in `eager_load!'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/engine.rb:436:in `each'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/engine.rb:436:in `eager_load!'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/application/finisher.rb:53
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `instance_exec'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `run'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/initializable.rb:55:in `run_initializers'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `each'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `run_initializers'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/application.rb:136:in `initialize!'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/railtie/configurable.rb:30:in `send'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /var/www/redmine/config/environment.rb:14
from /var/www/redmine/config.ru:4:in `require'
from /var/www/redmine/config.ru:4
from /usr/lib64/ruby/gems/1.8/gems/rack-1.4.0/lib/rack/builder.rb:51:in `instance_eval'
from /usr/lib64/ruby/gems/1.8/gems/rack-1.4.0/lib/rack/builder.rb:51:in `initialize'
from /var/www/redmine/config.ru:1:in `new'
from /var/www/redmine/config.ru:1
编辑:我想通了......我需要运行命令:RAILS_ENV=production bundle exec rake db:migrate
哦!