0

当我说bundle install一段时间后我得到错误:

结果记录到/Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/mysql2-0.3.11/ext/mysql2/gem_make.out 安装mysql2(0.3.11)时出错,并且 Bundler 无法继续。gem install mysql2 -v '0.3.11'在捆绑之前确保成功。

所以我按照它说的做,我运行这个命令:

gem install mysql2 -v '0.3.11'

然后我再次运行 Bundle Install 但我再次遇到相同的错误。

我应该从哪里着手解决这个问题?

这是我的 GemFile 的样子:

source 'https://rubygems.org'

gem 'rails', '3.2.6'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
#START:mysql
group :production do
  gem 'mysql2'
end
#END:mysql

# 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
#START_HIGHLIGHT
gem 'capistrano'
#END_HIGHLIGHT

# To use debugger
# gem 'debugger'

gem 'will_paginate', '~> 3.0'
4

1 回答 1

1

此错误的原因可能是缺少 mysql 标头,因此请确保您已正确安装 mysql 标头。

对于 Ubuntu/Linux 风格,使用以下命令安装 MySQL 客户端和开发包

sudo apt-get install mysql-client libmysqlclient-dev

对于 Mac 操作系统:

http://www.djangoapp.com/blog/2011/07/24/installation-of-mysql-server-on-mac-os-x-lion/

问候!

于 2013-01-22T20:38:56.997 回答