无法安装mysql2宝石OS X山狮(Unable to install mysql2 gem OS

2019-06-27 01:06发布

我是新与回报率,我试图安装Mysql2 -v“0.3.11”。 我有OS X山狮,导轨3.2.6,1.9.3红宝石。

下面是我的错误。 我到处找,没有发现任何东西。

$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

谢谢你的帮助。

Answer 1:

您使用的是带有10.8红宝石的RVM代替。 好。 现在,停止使用自带的10.8 MySQL的。

安装和更新家酿 。 现在运行

brew install mysql

使用/Gemfile在您的项目安装mysql2宝石。 加

gem "mysql2"

/Gemfile 。 然后通过运行更新捆扎机您的应用程序

bundle install

让你的包管理器(家酿和捆扎机)工作。

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



Answer 2:

作为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 ,这一切从此非常顺利。



Answer 3:

我也得到相同类型mac10.10错误且低于为我工作的命令使用:

  1. 安装和使用升级家酿:

    BREW安装mysql

  2. 运行使用安装MySQL的宝石文件:

    创业板安装mysql2 -v '0.3.11'

  3. 运行安装包



文章来源: Unable to install mysql2 gem OS X Mountain Lion