【问题标题】:Can not install Mysql gem on Ubuntu server无法在 Ubuntu 服务器上安装 Mysql gem
【发布时间】:2015-09-10 07:08:57
【问题描述】:

我在 gem 文件中添加了 mysql gem,但是当我运行 bundle install 时,它显示以下错误。

An error occurred while installing mysql (2.9.1), and Bundler cannot continue. Make sure that `gem install mysql -v '2.9.1'` succeeds before bundling.

我正在我的 Ubuntu 机器上安装这个 gem。我使用的是 rails 版本 4.2.0 和 ruby​​ 2.1.7。我在下面解释 mu gemfile。

宝石文件:

source 'https://rubygems.org'
ruby '2.1.7'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0'
# Use postgresql as the database for Active Record
gem 'pg', '~> 0.18.2'
gem 'mysql', '~> 2.9.1'
gem 'postgres_ext', '~> 2.4.1'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails', '~> 4.0.3'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks', '~> 2.5.3'
gem 'jquery-turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

gem 'bootstrap-sass', '~> 3.3.4'
gem 'font-awesome-sass', '~> 4.2.0'

gem 'devise', '~> 3.4.1'
gem 'devise_invitable', '~> 1.5.0'
gem 'omniauth-facebook', '~> 2.0'
gem 'omniauth-google-oauth2', '~> 0.2.6'
gem 'simple_form', '~> 3.1.0'
gem 'cancancan', '~> 1.9.2'

gem 'will_paginate', '~> 3.0.7'
gem 'will_paginate-bootstrap', '~> 1.0.1'

# Use this only for admin related filters
gem 'ransack', '~> 1.5.1'

# Enums: single & multi value, integrates with ActiveRecord, simple_form
gem 'enumerize', '~> 0.9.0'

# Image processing
gem 'mini_magick', '~> 4.0.1'

# File uploads
gem 'fog', '~> 1.27' #, require: 'fog/aws/storage'
gem 'carrierwave', '~> 0.10.0'

# Phone number validation
gem 'phonelib', '~> 0.4.0'

# Nested forms
gem 'cocoon', '~> 1.2.6'

gem 'combined_time_select', '~> 1.0.1'

# For file uploads
gem 'jquery-fileupload-rails', '~> 0.4.4'

# jquery light gallery
gem 'light_gallery_rails', git: 'https://github.com/stNicolaas/light-gallery-rails.git'

# Background processing
gem 'que', '~> 0.9.2'

gem 'rails-timeago', '~> 2.11.1'

gem 'listjs-rails', '~> 1.1.1'

gem 'selectize-rails', '~> 0.12.0'
gem 'client_side_validations', git: 'https://github.com/DavyJonesLocker/client_side_validations.git'
gem 'client_side_validations-simple_form', git: 'https://github.com/DavyJonesLocker/client_side_validations-simple_form.git'

gem 'validate_url', '~> 1.0.0'

gem 'friendly_id', '~> 5.1.0'

gem 'bootstrap-slider-rails', git: 'https://github.com/stationkeeping/bootstrap-slider-rails.git'

gem 'recaptcha', '~> 0.4.0', require: 'recaptcha/rails'

gem 'google-analytics-turbolinks', '~> 0.0.4'

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
    # Call 'byebug' anywhere in the code to stop execution and get a debugger console
    gem 'byebug'

    # Access an IRB console on exception pages or by using <%= console %> in views
    gem 'web-console', '~> 2.0'

    # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
    gem 'spring'

    # Exceute 'rspec' on command line to run tests
    gem 'rspec-rails', '~> 3.0'
    gem 'rspec-its'

    # Fixtures replacement
    gem "factory_girl_rails", "~> 4.0"

    # Fake data
    gem "faker"

    # rails environment variables
    gem 'figaro', '~> 1.1.1'
end

group :development do
    # Annotate models
    gem "annotate", "~> 2.6.5"
end

group :test do
    # See http://robots.thoughtbot.com/how-we-test-rails-applications > Database Cleaner
    gem 'database_cleaner', "~> 1.3.0"

    gem 'capybara', "~> 2.4.0"
end

group :production do
    gem 'mandrill_dm', '~> 1.2.0'
end

请帮我解决这个错误。

【问题讨论】:

    标签: mysql ruby ruby-on-rails-4 gem ubuntu-14.04


    【解决方案1】:

    试试

    sudo apt-get install libmysqlclient-dev 
    

    如果这没有帮助,请在此处粘贴您遇到的错误。

    【讨论】:

    • 你的回答对我有帮助,但是在运行服务器后它显示这个Migrations are pending. To resolve this issue, run: bin/rake db:migrate RAILS_ENV=development 错误。你能帮我解决这个错误吗?
    • 这不是一个错误。您可以通过迁移管理您的数据库,您可以在此处了解它们:edgeguides.rubyonrails.org/active_record_migrations.html 只需在控制台中运行该命令,同时位于项目的根目录。
    猜你喜欢
    • 2015-09-23
    • 1970-01-01
    • 2016-09-07
    • 1970-01-01
    • 2013-06-21
    • 2018-04-03
    • 2013-01-22
    • 2017-11-10
    • 2014-10-20
    相关资源
    最近更新 更多