微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Rails 4.2.2 – mysql2安装错误

@H_404_0@在rails 4.2.2环境中,我正在尝试为一个示例项目运行bundle install,但是我收到如下错误

@H_404_0@Gem :: Ext :: BuildError:错误:无法构建gem原生扩展.

@H_404_0@

/home/aparna/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20150912- 2709-1b70inv.rb extconf.rb 
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for MysqL.h... yes
checking for errmsg.h... yes
checking for MysqLd_error.h... yes
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling MysqL2_ext.c
In file included from ./client.h:11:0,
             from ./MysqL2_ext.h:39,
             from MysqL2_ext.c:1:
/home/aparna/.rvm/rubies/ruby-2.2.1/include/ruby-2.2.0/ruby/backward/rubysig.h:14:2: warning: #warning rubysig.h is obsolete [-Wcpp]
#warning rubysig.h is obsolete
^
In file included from ./MysqL2_ext.h:39:0,
             from MysqL2_ext.c:1:
./client.h: In function ‘rb_thread_blocking_region’:
./client.h:23:3: error: ‘TRAP_BEG’ undeclared (first use in this function)
TRAP_BEG;
^
./client.h:23:3: note: each undeclared identifier is reported only once for each function it appears in
./client.h:25:3: error: ‘TRAP_END’ undeclared (first use in this function)
TRAP_END;
^
MysqL2_ext.c: At top level:
./client.h:16:1: warning: ‘rb_thread_blocking_region’ defined but not used [-Wunused-function]
rb_thread_blocking_region(
^
make: *** [MysqL2_ext.o] Error 1

make Failed, exit code 2

Gem files will remain installed in /home/aparna/.rvm/gems/ruby-2.2.1/gems/MysqL2-0.3.13 for inspection.
Results logged to /home/aparna/.rvm/gems/ruby-2.2.1/extensions/x86_64-linux/2.2.0/MysqL2-0.3.13/gem_make.out
An error occurred while installing MysqL2 (0.3.13), and Bundler cannot continue.
Make sure that `gem install MysqL2 -v '0.3.13'` succeeds before bundling.
@H_404_0@Gemfile是,

@H_404_0@

source 'https://rubygems.org'

gem 'rails', '4.2.0'
gem 'MysqL2', '0.3.13'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'therubyracer', platforms: :ruby

gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc

group :development, :test do
 gem 'byebug'
 gem 'web-console', '~> 2.0'
 gem 'spring'
end

gem 'protected_attributes'

gem 'devise'

gem 'paperclip'
gem "cocaine"

gem "simple_form"

gem "less-rails" #Sprockets (what Rails 3.1 uses for its asset pipeline) supports LESS
gem "twitter-bootstrap-rails"

gem 'kristin'
gem 'docsplit'
gem 'pdf2html'
@H_404_0@我已经尝试安装MysqL2然后安装了MysqL2(0.4.0),但这会在启动rails服务器时显示以下错误

@H_404_0@

/home/aparna/.rvm/gems/ruby-2.2.1/gems/activerecord-4.2.0/lib/active_record/connection_adapters/connection_specification.rb:177:in `rescue in spec': Specified 'MysqL2' for database adapter, but the gem is not loaded. Add `gem 'MysqL2'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord). (Gem::LoadError)
@H_404_0@我该如何解决MysqL2安装问题?

解决方法:

@H_404_0@MysqL2-0.4.0版本中有一个错误,请查看neighbor question

@H_404_0@尝试安装最新的MysqL2-0.3.x版本:

@H_404_0@更改Gemfile:

@H_404_0@

 gem 'MysqL2', '~> 0.3.13'
@H_404_0@并运行

@H_404_0@

bundle update MysqL2
@H_404_0@确保通过弹簧挡块停止弹簧,然后启动导轨.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐