-1

我刚刚用 ruby​​ 开始一个项目(在 Windows 上),当我运行 'rails server' 时,我有这个 ince ,essage:

C:\Sites\rails_projects\first_app>rails 服务器 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql-2.9.1-x86-mingw32/lib /mysql.rb:6:在require': cannot load such file -- mysql/mysql_api (LoadError) from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql-2.9.1-x8 6-mingw32/lib/mysql.rb:6:in救援中来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql-2.9.1-x8 6-mingw32/lib/mysql.rb:2:in <top (required)>' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/ lib/bundler/runtime.rb:72:inrequire' 来自 C :/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in block (2 levels) in require' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/ lib/bundler/runtime.rb:70:ineach' 来自 C:/RailsInstaller/Ruby1.9.3/lib /ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in block in require' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/ lib/bundler/runtime.rb:59:ineach' 来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/ gems/bundler-1.3.5/lib/bundler/runtime.rb:59:inrequire' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/ lib/bundler.rb:132:in需要'来自 C:/Sites/rails_projects/first_app/config/application.rb:7:in<top (required)>' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 3/lib/rails/commands.rb:53:in需要'来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 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.1 3/lib/rails/commands.rb:50:intap'来自 C:/RailsInstaller/ Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 3/lib/rails/commands.rb:50:in <top (required)>' from script/rails:6:inrequire' from script/rails:6:in `'

当然,我错过了什么。这是我的 Gemfile:来源“ https://rubygems.org

gem 'rails', '3.2.13'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'bundler'
gem 'sqlite3'
gem 'mysql'
gem 'geocode'
gem 'gmaps4rails'
gem 'railties'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

  gem 'uglifier', '>= 1.0.3'
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'

# To use debugger
# gem 'debugger'

因为我刚刚开始,所以我没有 ruby​​ 代码文件(或者我有一个,当你创建一个新的铁路项目时生成的那个)。

提前致谢,


感谢您的快速回答,但不幸的是我遇到了同样的错误:

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': 126: Le module spécifié est introuvable. - C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/ lib/mysql2/1.9/mysql2.so (LoadError) 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'来自 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'来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/ gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in require' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/ lib/bundler/runtime.rb:72:inblock (2 levels) in require' 来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9 .1/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in each' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/ lib/bundler/runtime.rb:70:inblock in require' 来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler- 1.3.5/lib/bundler/runtime.rb:59:in each' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/ lib/bundler/runtime.rb:59:inrequire' 来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler.rb :132:在require' from C:/Sites/rails_projects/first_app/config/application.rb:7:in'来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 3/lib/rails/commands.rb:53:in require' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 3/lib/rails/commands.rb:53:inblock in '来自 C:/RailsInstaller/ Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 3/lib/rails/commands.rb:50:in tap' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 3/lib/rails/commands.rb:50:in' 来自 script/rails:6:in require' from script/rails:6:in'

My files : Gemfile
source 'https://rubygems.org'

gem 'rails', '3.2.13'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'bundler'
# gem 'sqlite3'
gem 'mysql2', '~> 0.3.11'
gem 'geocode'
gem 'gmaps4rails'
gem 'railties'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

  gem 'uglifier', '>= 1.0.3'
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'

# To use debugger
# gem 'debugger'

数据库.yml

# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'mysql2'
development:
  adapter: mysql2
  database: db/development.mysql2
  pool: 5
  timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: mysql2
  database: db/test.mysql2
  pool: 5
  timeout: 5000

production:
  adapter: mysql2
  database: db/production.mysql2
  pool: 5
  timeout: 5000

再次感谢你的帮助,

4

1 回答 1

0

不要同时包含sqlite3gem 和mysqlgem。

  1. 删除现有Gemfile.lock文件。

  2. 消除gem 'sqlite3'

  3. 替换gem 'mysql'gem 'mysql2', '~> 0.3.11'

  4. 运行并重bundle install试。

另外,请确保您的系统中安装了 mysql。并配置您config/database.yml使用 mysql 适配器development

编辑:
将您的libmysql.dllfrom C:\Program Files\MySQL\MySQL version\bin(它必须存在,取决于您的 MySQL 版本等)复制到C:/RailsInstaller/Ruby1.9.3/bin.

于 2013-05-12T12:44:27.910 回答