2012-05-23 29 views
6

Tôi tạo ra một đường ray dự án mới gọisai MySQL thư viện client phiên bản

rails new simple_cms 

Sau đó, khi trong thư mục tôi chạy

rails s 

tôi nhận được lỗi sau

C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/l 
ib/mysql2/mysql2.rb:2:in `require': Incorrect MySQL client library version! This 
gem was compiled for 6.0.0 but the client library is 5.5.24. (RuntimeError) 
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11- 
x86-mingw32/lib/mysql2/mysql2.rb:2:in `<top (required)>' 
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11- 
x86-mingw32/lib/mysql2.rb:9:in `require' 
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11- 
x86-mingw32/lib/mysql2.rb:9:in `<top (required)>' 
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/ 
lib/bundler/runtime.rb:68:in `require' 
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/ 
lib/bundler/runtime.rb:68:in `block (2 levels) in require' 
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/ 
lib/bundler/runtime.rb:66:in `each' 
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/ 
lib/bundler/runtime.rb:66:in `block in require' 
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/ 
lib/bundler/runtime.rb:55:in `each' 
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/ 
lib/bundler/runtime.rb:55:in `require' 
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/ 
lib/bundler.rb:119:in `require' 
    from c:/development/ruby/simple_cms/config/application.rb:7:in `<top (re 
quired)>' 
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.3 
/lib/rails/commands.rb:53:in `require' 
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.3 
/lib/rails/commands.rb:53:in `block in <top (required)>' 
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.3 
/lib/rails/commands.rb:50:in `tap' 
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.3 
/lib/rails/commands.rb:50:in `<top (required)>' 
    from script/rails:6:in `require' 
    from script/rails:6:in `<main>' 

Tôi có nhìn thấy những người khác với lỗi này nhưng họ có xu hướng là người dùng Linux và tôi đang chạy các cửa sổ. Tôi đã cố gắng cài đặt lại cả hai đường ray (railsinstaller.org) và mysql 5.5. Tôi đã sử dụng cả phiên bản 32 bit cũng như phiên bản 64bit

+0

+1 để hỏi câu hỏi liên quan – neeraj

Trả lời

13

Có vẻ như đã có một số câu hỏi về vấn đề này. Bạn đã thử giải pháp của họ chưa?

Có lẽ rõ ràng nhất là thế này: mysql2 gem compiled for wrong mysql client library

Phần thích hợp là ở đây:

At the time of building this gem, the necessary DLL files where available 
in the following download: 

http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip/from/pick 

And put lib\libmysql.dll file in your Ruby bin directory, for example 
C:\Ruby\bin 
+0

tôi đã thấy câu hỏi đó. tôi đã bỏ lỡ bước cuối cùng về việc di chuyển libmysql.dll. bây giờ nó hoạt động. cảm ơn! – mhopkins321

+1

+1 để tiết kiệm rất nhiều nỗ lực của tôi – neeraj

0

Tôi có lỗi này trong một dự án mới, tôi đã làm việc trên đó đột nhiên dừng lại làm việc trong một cửa sổ máy đã có các dự án đường ray làm việc, vì vậy rõ ràng đó không phải là một vấn đề cài đặt.

Điều gì gây ra sự cố là lệnh bundle update, quyết định tải xuống lại đá quý mysql2 (vì lý do không xác định) và bỏ qua gem gem của tôi Gemfile 'mysql2', '~> 0.2.6'.

Vấn đề là bó cập nhật có mysql phiên bản 0.2.18, như thể hiện trong Gemfile.lock, trong dòng sau:

mysql2 (0.2.18-x86-mingw32) 

Tôi lưu ý chắc chắn những gì biểu tượng có nghĩa, nhưng tôi đã thay thế dòng sau đây vào gemfile tôi

gem 'mysql2', '~> 0.2.6' 

cho

gem 'mysql2', '0.2.6' 

Và bây giờ tất cả mọi thứ hoạt động tốt, bao gồm bundle update.

4

Điều này sẽ loại bỏ đá quý và các phụ thuộc của nó. Sau đó cài đặt lại sẽ tự biên dịch lại và tất cả các phụ thuộc.

gem uninstall mysql2 
bundle install 
Các vấn đề liên quan