1
我想將我的rails應用程序從rails版本3遷移到rails版本4.我在我的rails應用程序中安裝了mysql2 gem並試圖運行rails服務器,但是我得到下面錯誤。Rails:當啓動rails服務器時mysql加載錯誤
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/act
ive_support/dependencies.rb:228:in `require': cannot load such file -- mysql2/2.
0/mysql2 (LoadError)
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-
4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-
4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-
4.0.0/lib/active_support/dependencies.rb:228:in `require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11-
x86-mingw32/lib/mysql2/mysql2.rb:2:in `<top (required)>'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-
4.0.0/lib/active_support/dependencies.rb:228:in `require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-
4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-
4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-
4.0.0/lib/active_support/dependencies.rb:228:in `require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11-
x86-mingw32/lib/mysql2.rb:9:in `<top (required)>'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:76:in `require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:72:in `each'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:72:in `block in require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:61:in `each'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:61:in `require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.7.7/
lib/bundler.rb:133:in `require'
from E:/JCI-stable-final-Version-7-AoneSms/onspot-rails4.0.0/config/appl
ication.rb:12:in `<top (required)>'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.0.0
/lib/rails/commands.rb:76:in `require'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.0.0
/lib/rails/commands.rb:76:in `block in <top (required)>'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.0.0
/lib/rails/commands.rb:73:in `tap'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.0.0
/lib/rails/commands.rb:73:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
下面是我的Gemfile
source 'http://rubygems.org'
gem 'gmaps4rails'
gem 'geocoder'
gem 'groupdate'
gem "chartkick"
gem "paperclip"
gem "easy_captcha"
gem "rails_email_validator"
gem "devise_security_extension"
gem "will_paginate"
gem "prawn-labels"
gem "rails-xmlrpc"
gem "rqrcode_png"
gem "rqrcode"
gem "blueprint-rails"
gem "mysql2" , "0.3.11"
gem "jeweler"
#gem "activesupport"
#gem "activerecord"
#gem "activerecord-import"
#gem "activerecord-mysql-adapter"
#gem "mysql"
gem "yaml_db"
gem "tabulous"
gem "thin"
gem 'rails', '4.0.0'
gem "rake"
gem 'jquery-ui-rails'
gem 'cancan'
gem 'rolify'
gem 'rails_admin'
gem 'fastercsv'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
#gem 'sqlite3'
gem "devise"
#gem "devise", "~> 1.5.3"
#gem "orm_adapter", "~> 0.0.3"
gem 'json'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 4.0.0'
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.3.0'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
gem 'capistrano'
#gem 'css-bootstrap-rails'
# To use debugger
# gem 'ruby-debug'
gem 'impressionist'
gem 'devise-encryptable'
gem "devise_invitable"
請幫助。
感謝
我試過但得到相同的錯誤。 – user2274074 2015-01-21 09:50:29
更新的答案,我沒有注意到你在windows中遇到了這個錯誤。希望這有助於:) – Ajay 2015-01-21 09:53:49
我試過它上面的命令和寶石是安裝sucesffully。但仍然得到相同的問題..當我做捆綁安裝我得到http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0 .2-win32.zip /從/選擇 並將lib \ libmysql.dll文件放入您的Ruby bin目錄中,例如C:\ Ruby \ bin消息 – user2274074 2015-01-21 10:02:57