6

Tôi đang chạy CentOS6 và cài đặt Ruby từ nguồn, cùng với Rails và một số nhân viên khác.Rails, Ruby 1.9.3p0 và mysql gem

ruby -v 
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux] 

rails -v 
Rails 3.1.3 

Một số đá quý:

 
*** LOCAL GEMS *** 

actionmailer (3.1.3, 2.3.14) 
actionpack (3.1.3, 2.3.14) 
activemodel (3.1.3) 
activerecord (3.1.3, 2.3.14) 
activeresource (3.1.3, 2.3.14) 
activesupport (3.1.3, 2.3.14) 
archive-tar-minitar (0.5.2) 
arel (2.2.1) 
bigdecimal (1.1.0) 
bouncy-castle-java (1.5.0146.1) 
builder (3.0.0) 
bundler (1.0.21) 
coderay (0.9.7) 
columnize (0.3.5) 
edavis10-object_daddy (0.4.3) 
erubis (2.7.0) 
fastercsv (1.5.0) 
ffi (1.0.11) 
hike (1.2.1) 
hoe (2.12.4) 
i18n (0.6.0, 0.4.2) 
io-console (0.3) 
jruby-openssl (0.7.4) 
json (1.5.4) 
linecache19 (0.5.13) 
mail (2.3.0) 
metaclass (0.0.1) 
mime-types (1.17.2) 
minitest (2.5.1) 
mocha (0.10.0) 
multi_json (1.0.4) 
mysql (2.8.1) 
mysql2 (0.3.11, 0.2.7) 
net-ldap (0.2.2) 
polyglot (0.3.3) 
rack (1.3.5, 1.1.2) 
rack-cache (1.1) 
rack-mount (0.8.3) 
rack-ssl (1.3.2) 
rack-test (0.6.1) 
rails (3.1.3, 2.3.14) 
railties (3.1.3) 
rake (0.9.2.2) 
rdoc (3.9.4) 
rmagick (2.13.1) 
ruby-debug-base19 (0.11.26, 0.11.25) 
ruby-debug19 (0.11.6) 
ruby-mysql (2.9.4) 
ruby-openid (2.1.4) 
ruby_core_source (0.1.5) 
rubygems-update (1.8.12) 
rubytree (0.5.2) 
shoulda (2.11.3, 2.10.3) 
sprockets (2.0.3) 
sqlite3 (1.3.5, 0.1.1) 
sqlite3-ruby (1.3.3, 1.2.5) 
thor (0.14.6) 
tilt (1.3.3) 
treetop (1.4.10) 
tzinfo (0.3.31) 

Tôi cần Rails để chạy chiliproject, nhưng khi chạy lệnh sau

RAILS_ENV=production bundle exec rake db:migrate 

tôi nhận được:

 
!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql. 
rake aborted! 
cannot load such file -- mysql 

Tasks: TOP => db:migrate => environment 
(See full trace by running task with --trace) 

Bây giờ với --trace:

 
RAILS_ENV=production bundle exec rake db:migrate --trace >> tmp/rake 
** Invoke db:migrate (first_time) 
** Invoke environment (first_time) 
** Execute environment 
!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql. 
rake aborted! 
cannot load such file -- mysql 
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:184:in `require' 
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:184:in `require' 
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.14/lib/active_support/core_ext/kernel/requires.rb:7:in `block in require_library_or_gem' 
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.14/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings' 
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.14/lib/active_support/core_ext/kernel/requires.rb:5:in `require_library_or_gem' 
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.14/lib/active_record/connection_adapters/mysql_adapter.rb:61:in `mysql_connection' 
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.14/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in `new_connection' 
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.14/lib/active_record/connection_adapters/abstract/connection_pool.rb:245:in `checkout_new_connection' 
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.14/lib/active_record/connection_adapters/abstract/connection_pool.rb:188:in `block (2 levels) in checkout' 
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.14/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in `loop' 
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.14/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in `block in checkout' 
/usr/local/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize' 
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.14/lib/active_record/connection_adapters/abstract/connection_pool.rb:183:in `checkout' 
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.14/lib/active_record/connection_adapters/abstract/connection_pool.rb:98:in `connection' 
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.14/lib/active_record/connection_adapters/abstract/connection_pool.rb:326:in `retrieve_connection' 
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.14/lib/active_record/connection_adapters/abstract/connection_specification.rb:123:in `retrieve_connection' 
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.14/lib/active_record/connection_adapters/abstract/connection_specification.rb:115:in `connection' 
/var/www/html/chiliproject/vendor/plugins/awesome_nested_set/lib/awesome_nested_set.rb:218:in `quoted_left_column_name' 
/var/www/html/chiliproject/vendor/plugins/awesome_nested_set/lib/awesome_nested_set.rb:94:in `acts_as_nested_set' 
/var/www/html/chiliproject/app/models/issue.rb:33:in `' 
/var/www/html/chiliproject/app/models/issue.rb:15:in `' 
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:184:in `require' 
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:184:in `require' 
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:291:in `require_or_load' 
/var/www/html/chiliproject/vendor/plugins/engines/lib/engines/rails_extensions/dependencies.rb:133:in `require_or_load_with_engine_additions' 
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:451:in `load_missing_constant' 
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:106:in `const_missing_with_dependencies' 
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:118:in `const_missing' 
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.14/lib/active_support/inflector.rb:375:in `const_get' 
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.14/lib/active_support/inflector.rb:375:in `block in constantize' 
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.14/lib/active_support/inflector.rb:374:in `each' 
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.14/lib/active_support/inflector.rb:374:in `constantize' 
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.14/lib/active_support/core_ext/string/inflections.rb:162:in `constantize' 
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.14/lib/active_record/observer.rb:157:in `observed_class' 
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.14/lib/active_record/observer.rb:183:in `observed_classes' 
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.14/lib/active_record/observer.rb:166:in `initialize' 
/usr/local/lib/ruby/1.9.1/singleton.rb:141:in `new' 
/usr/local/lib/ruby/1.9.1/singleton.rb:141:in `block in instance' 
:10:in `synchronize' 
/usr/local/lib/ruby/1.9.1/singleton.rb:139:in `instance' 
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.14/lib/active_record/observer.rb:38:in `block in instantiate_observers' 
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.14/lib/active_record/observer.rb:36:in `each' 
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.14/lib/active_record/observer.rb:36:in `instantiate_observers' 
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.14/lib/action_controller/dispatcher.rb:15:in `block in define_dispatcher_callbacks' 
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.14/lib/active_support/callbacks.rb:182:in `call' 
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.14/lib/active_support/callbacks.rb:182:in `evaluate_method' 
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.14/lib/active_support/callbacks.rb:166:in `call' 
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.14/lib/active_support/callbacks.rb:90:in `block in run' 
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.14/lib/active_support/callbacks.rb:90:in `each' 
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.14/lib/active_support/callbacks.rb:90:in `run' 
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.14/lib/active_support/callbacks.rb:276:in `run_callbacks' 
/usr/local/lib/ruby/gems/1.9.1/gems/actionpack-2.3.14/lib/action_controller/dispatcher.rb:51:in `run_prepare_callbacks' 
/usr/local/lib/ruby/gems/1.9.1/gems/rails-2.3.14/lib/initializer.rb:631:in `prepare_dispatcher' 
/usr/local/lib/ruby/gems/1.9.1/gems/rails-2.3.14/lib/initializer.rb:185:in `process' 
/usr/local/lib/ruby/gems/1.9.1/gems/rails-2.3.14/lib/initializer.rb:113:in `run' 
/var/www/html/chiliproject/config/environment.rb:39:in `' 
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:182:in `require' 
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:182:in `block in require' 
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:547:in `new_constants_in' 
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:182:in `require' 
/usr/local/lib/ruby/gems/1.9.1/gems/rails-2.3.14/lib/tasks/misc.rake:4:in `block in ' 
/usr/local/lib/ruby/1.9.1/rake/task.rb:205:in `call' 
/usr/local/lib/ruby/1.9.1/rake/task.rb:205:in `block in execute' 
/usr/local/lib/ruby/1.9.1/rake/task.rb:200:in `each' 
/usr/local/lib/ruby/1.9.1/rake/task.rb:200:in `execute' 
/usr/local/lib/ruby/1.9.1/rake/task.rb:158:in `block in invoke_with_call_chain' 
/usr/local/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize' 
/usr/local/lib/ruby/1.9.1/rake/task.rb:151:in `invoke_with_call_chain' 
/usr/local/lib/ruby/1.9.1/rake/task.rb:176:in `block in invoke_prerequisites' 
/usr/local/lib/ruby/1.9.1/rake/task.rb:174:in `each' 
/usr/local/lib/ruby/1.9.1/rake/task.rb:174:in `invoke_prerequisites' 
/usr/local/lib/ruby/1.9.1/rake/task.rb:157:in `block in invoke_with_call_chain' 
/usr/local/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize' 
/usr/local/lib/ruby/1.9.1/rake/task.rb:151:in `invoke_with_call_chain' 
/usr/local/lib/ruby/1.9.1/rake/task.rb:144:in `invoke' 
/usr/local/lib/ruby/1.9.1/rake/application.rb:116:in `invoke_task' 
/usr/local/lib/ruby/1.9.1/rake/application.rb:94:in `block (2 levels) in top_level' 
/usr/local/lib/ruby/1.9.1/rake/application.rb:94:in `each' 
/usr/local/lib/ruby/1.9.1/rake/application.rb:94:in `block in top_level' 
/usr/local/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handling' 
/usr/local/lib/ruby/1.9.1/rake/application.rb:88:in `top_level' 
/usr/local/lib/ruby/1.9.1/rake/application.rb:66:in `block in run' 
/usr/local/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handling' 
/usr/local/lib/ruby/1.9.1/rake/application.rb:63:in `run' 
/usr/local/bin/rake:32:in `' 
Tasks: TOP => db:migrate => environment 

Có ai biết điều gì sai với tệp gem mysql không?

Tôi cũng đã cố gắng để cài đặt file ngọc mysql như thế này

gem install ruby-mysql2 --no-rdoc --no-ri -- --with-mysql-config=/usr/bin/mysql_config 

Trả lời

8

Tôi chỉ gặp vấn đề tương tự và bạn có thể làm những gì tôi là: Tôi đã sử dụng 'danh sách đá quý' để xác định những gì đã được cài đặt (nó danh sách *** LOCAL GEMS *** giống như bạn hiển thị) và tôi thấy mysql, nhưng Gemfile cho dự án của tôi không yêu cầu bundler để cài đặt mysql.

Nếu bạn chỉ nhập bundle show danh sách 'mysql' có được liệt kê không? Nếu không, thì Gemfile trong chiliproject sẽ không gây ra bundler để cài đặt mysql. Tôi thấy tất cả điều này rất khó hiểu cho đến khi tôi nhận ra rằng tôi đã nhầm lẫn các cách quản lý những viên đá quý nào được cài đặt.

Nếu bạn hoặc những người khác đến theo cách này đang gặp vấn đề tương tự, thì có lẽ điều này hữu ích. (Và có lẽ lời giải thích tồi tệ này sẽ khuyến khích một trong những bậc thầy kinh nghiệm xây dựng cho chúng tôi.)

Nói cách khác, danh sách các viên đá quý được cài đặt cục bộ của bạn không giống với danh sách được cài đặt trong ứng dụng của bạn đá quý (do đó tên của công cụ bundler xuất phát từ). Khi bạn đang chạy ứng dụng của mình và quản lý các phụ thuộc của nó với bundler, bạn phải thực hiện mọi thứ trong phạm vi bundler để đảm bảo tất cả hoạt động cùng nhau. Khi bạn làm điều đó nó thực sự rất thẳng về phía trước và giải quyết rất nhiều vấn đề cho bạn, nhưng nếu bạn đến từ kinh nghiệm trước đó trên các ứng dụng không sử dụng bundler thì nó chỉ mất một chút làm quen với.

+0

Cảm ơn @normalocity - điều đó rất hữu ích. Tôi có chính xác rằng điều này cho phép * bundle * để sản xuất không đồng bộ hóa với gói * * để phát triển không? (Nếu vậy, điều đó sẽ giúp tôi cách ly một vấn đề khác.) – sage

+0

Trong thực tế, không nên có sự khác biệt giữa gói * phát triển * và * sản xuất *. Bạn đang chạy vào một tình huống mà điều này đang xảy ra (có nghĩa là, nơi 'bó show' không hiển thị cùng một điều trong cả hai phát triển và sản xuất)? Ngoại trừ các đá quý chỉ cần thiết để thử nghiệm (ví dụ: 'dưa chuột',' rspec', v.v.), danh sách phải giống nhau. – jefflunt

+0

Cảm ơn rất nhiều !!! – user846226

2

2 bước mà làm việc cho tôi:

  1. Copy file libmysql.dll từ /libhttp://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c- noinstall-6.0.2-win32.zip/from/pick (trong thư mục/lib /) trong c:/your/path/to/ruby ​​/ bin (Hãy chắc chắn rằng thùng ruby ​​của bạn nằm trong biến môi trường PATH của hệ thống)

  2. Thiết lập mặc định được cung cấp cho MySQL với ruby1.8. Nếu bạn đang chạy Redmine với MySQL và ruby1.9, hãy thay thế tên bộ điều hợp bằng mysql2 trong/config/database của bạn.tập tin yml http://www.redmine.org/issues/10566

2

Chỉ cần trên bó cài đặt thử này >>

bundle install --without=test development sqlite postgres mysql rmagick

này sẽ cài đặt tất cả phụ thuộc căn cứ yêu cầu, cơ sở dữ liệu mysql2 bộ chuyển đổi Nguyên nhân mysql bộ chuyển đổi là không tương thích với Ruby 1.9

Và đừng quên thay đổi config/database.yml -> s/mysql/mysql2

\ o/

+0

Tôi chỉ có vấn đề này trên một dự án cũ (ruby 1.8) và 'database.yml' là vấn đề! quên thay thế 'mysql' thành' mysql2' trong đó. – caesarsol

Các vấn đề liên quan