如何在ruby on rail中修复此错误.

source 'https://rubygems.org'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.2'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# 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.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
gem 'mysql 2', '0.4.8'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# 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', platform: :mri
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '~> 3.0.5'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

gem 'spree', '~> 3.2.1'
gem 'spree_auth_devise', github: 'spree/spree_auth_devise'
gem 'spree_gateway', github: 'spree/spree_gateway'
gem 'spree_i18n', github: 'spree-contrib/spree_i18n', branch: 'master'

我运行了"bundle安装",出现了这个错误.

这个ruby on rails使用Spree框架.

编辑:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/admin/.rvm/gems/ruby-2.4.1/gems/mysql2-0.4.8/ext/mysql2
/Users/admin/.rvm/rubies/ruby-2.4.1/bin/ruby -r ./siteconf20170803-6579-foq4sg.rb extconf.rb
checking for rb_absint_size()... yes

我运行了"bundle install",但由于此错误,无法成功执行此命令.

推荐答案

我认为你错过了mysql的开发库:

On ubuntu

sudo apt-get install libmysqlclient-dev

On Red Hat/CentOS and other distributions using yum:

sudo yum install mysql-devel

On Mac OS X with Homebrew:

brew install mysql

Ruby-on-rails相关问答推荐

使用超级用户角色和未知密码创建与POSTRES用户的连接

无法在 Rails 中使用 wkhtmltopdf 写入临时文件

根据表单内的 Select 字段值渲染部分内容

使用has_many_through关联创建记录 – Ruby on Rails

CanCanCan、Pagy 和 Meil​​iSearch,如何组合这 3 个 gem?

如何使用 activerecord activerecord-session_store 在 Rails 应用程序中使用 cookie 值在数据库中查找会话记录

有没有一种简单的方法可以让 pow 为 https 服务?

Ruby的自动代码质量工具?

在 Windows 上使用 Ruby 进行开发

如何在 Linux 上使用 Ruby 2.0 改进独角兽进程之间的内存共享

Rails data-disable-with re-enable 按钮

Rails:在 lib 目录中记录代码?

如何在不删除项目本身的情况下删除单个 HABTM 关联项目?

可以在 Rails/ActiveRecord 中使用 NULL 指定唯一索引吗?

Rspec/Capybara 正在加载,循环要求被认为是有害的

按周/月/等和 ActiveRecord 分组?

你如何覆盖 form_for 助手中的类名?

Ruby 更新后:测试失败,assets资源 未声明为在生产中预编译

如何删除删除选项表单 activeAdmin?

设置EDITOR或BUNDLER_EDITOR环境变量