首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法安装mysql2 gem OS X Mountain Lion

无法安装mysql2 gem OS X Mountain Lion
EN

Stack Overflow用户
提问于 2012-08-14 11:33:35
回答 3查看 8.6K关注 0票数 6

我是RoR新手,正在尝试安装Mysql2 -v '0.3.11‘。我有OS X Mountain Lion,rails 3.2.6,ruby 1.9.3。

下面是我得到的错误。我到处找了看,什么也没找到。

代码语言:javascript
复制
$gem install mysql2 -v '0.3.11'
Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
ERROR: Failed to build gem native extension.

    /Users/curiosity/.rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
creating Makefile

make
compiling client.c
In file included from client.c:1:
In file included from ./mysql2_ext.h:8:
In file included from /Users/curiosity/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/ruby.h:32:
/Users/curiosity/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/ruby/ruby.h:105:37:     error: 'ruby_check_sizeof_long' declared as an array with a negative size
typedef char ruby_check_sizeof_long[SIZEOF_LONG == sizeof(long) ? 1 : -1];
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/curiosity/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/x86_64-darwin12.0.0/ruby/config.h:24:21: note: expanded from macro 'SIZEOF_LONG'
#define SIZEOF_LONG 8
                ^
In file included from client.c:1:
In file included from ./mysql2_ext.h:8:
In file included from /Users/curiosity/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/ruby.h:32:
/Users/curiosity/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/ruby/ruby.h:109:38: error: 'ruby_check_sizeof_voidp' declared as an array with a negative size
typedef char ruby_check_sizeof_voidp[SIZEOF_VOIDP == sizeof(void*) ? 1 : -1];
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/curiosity/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/x86_64-darwin12.0.0/ruby/config.h:28:22: note: expanded from macro 'SIZEOF_VOIDP'
#define SIZEOF_VOIDP 8
                 ^
In file included from client.c:1:
In file included from ./mysql2_ext.h:8:
In file included from /Users/curiosity/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/ruby.h:32:
In file included from /Users/curiosity/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/ruby/ruby.h:1377:
In file included from /Users/curiosity/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/ruby/intern.h:34:
/Users/curiosity/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/ruby/st.h:67:45: error: 'st_check_for_sizeof_st_index_t' declared as an array with a negative size
typedef char st_check_for_sizeof_st_index_t[SIZEOF_VOIDP == (int)sizeof(st_index_t) ? 1 : -1];
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/curiosity/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/x86_64-darwin12.0.0/ruby/config.h:28:22: note: expanded from macro 'SIZEOF_VOIDP'
#define SIZEOF_VOIDP 8
                 ^
3 errors generated.
make: *** [client.o] Error 1


Gem files will remain installed in /Users/curiosity/.rvm/gems/ruby-1.9.3-p125/gems/mysql2-0.3.11 for inspection.
Results logged to /Users/curiosity/.rvm/gems/ruby-1.9.3-p125/gems/mysql2-0.3.11/ext/mysql2/gem_make.out

谢谢你的帮助。

EN

回答 3

Stack Overflow用户

发布于 2012-08-14 11:50:34

您使用的是RVM,而不是10.8附带的Ruby。好的。现在,停止使用10.8附带的MySQL。

安装和更新。现在运行

代码语言:javascript
复制
brew install mysql

使用项目中的/Gemfile安装mysql2 gem。添加

代码语言:javascript
复制
gem "mysql2"

发送到您的/Gemfile。然后通过运行以下命令使用Bundler更新您的应用程序

代码语言:javascript
复制
bundle install

让包管理器(Homebrew和Bundler)为您工作。

这应该可以解决你所遇到的问题。

票数 27
EN

Stack Overflow用户

发布于 2012-12-27 10:54:38

正如Deefour所说,我必须使用RVM。答案是给他的,我对他的回答无可奉告。+1

但是rvm exec bundle install给了我一个错误:

rvm do bundle install已删除,请改用rvm 1.9.2,1.9.3 do bundle installrvm all do bundle install

我使用了sudo rvm all do bundle install,从那时起,一切都变得完美无瑕。

票数 0
EN

Stack Overflow用户

发布于 2015-10-17 04:06:02

我在mac10.10中也得到了相同类型的错误,并使用了以下适用于我的命令:

  1. 使用以下命令安装和升级Homebrew:

brew安装Mysql

  • 使用以下命令运行安装Mysql gem文件:

gem install mysql2 -v '0.3.11'

  • Run bundle install
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11945425

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档