在 Ruby 1.9.2 上安装 mysql2 gem 时出错
我目前正在尝试为 Ruby on Rails 应用程序安装 mysql2 gem。我正在使用 Ruby 1.9.2。错误如下:
todd-andrewss-macbook:shiftly toddOld$ gem install mysql2
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/Users/toddOld/.rvm/rubies/ruby-1.9.2-p0/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... yes
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
creating Makefile
make
gcc -I. -I/Users/toddOld/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/i386-darwin9.8.0 -I/Users/toddOld/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby/backward -I/Users/toddOld/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1 -I. -DHAVE_RB_THREAD_BLOCKING_REGION -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/usr/local/mysql/include -g -Os -arch x86_64 -fno-common -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL -fno-common -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long -fno-common -pipe -Wall -funroll-loops -o client.o -c client.c
In file included from /Users/toddOld/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby.h:32,
from ./mysql2_ext.h:4,
from client.c:1:
/Users/toddOld/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby/ruby.h:108: error: size of array ‘ruby_check_sizeof_long’ is negative
/Users/toddOld/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby/ruby.h:112: error: size of array ‘ruby_check_sizeof_voidp’ is negative
In file included from /Users/toddOld/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby/intern.h:29,
from /Users/toddOld/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby/ruby.h:1327,
from /Users/toddOld/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby.h:32,
from ./mysql2_ext.h:4,
from client.c:1:
/Users/toddOld/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby/st.h:69: error: size of array ‘st_check_for_sizeof_st_index_t’ is negative
client.c: In function ‘rb_raise_mysql2_error’:
client.c:79: warning: comparison is always true due to limited range of data type
client.c:79: warning: comparison is always true due to limited range of data type
client.c: In function ‘rb_mysql_client_socket’:
client.c:412: warning: comparison is always true due to limited range of data type
client.c:412: warning: comparison is always true due to limited range of data type
client.c: In function ‘init_mysql2_client’:
client.c:556: warning: comparison is always true due to limited range of data type
client.c:556: warning: comparison is always true due to limited range of data type
client.c:561: warning: comparison is always true due to limited range of data type
client.c:561: warning: comparison is always true due to limited range of data type
client.c:566: warning: comparison is always true due to limited range of data type
client.c:566: warning: comparison is always true due to limited range of data type
client.c:571: warning: comparison is always true due to limited range of data type
client.c:571: warning: comparison is always true due to limited range of data type
client.c:576: warning: comparison is always true due to limited range of data type
client.c:576: warning: comparison is always true due to limited range of data type
client.c:580: warning: comparison is always true due to limited range of data type
client.c:580: warning: comparison is always true due to limited range of data type
client.c:584: warning: comparison is always true due to limited range of data type
client.c:584: warning: comparison is always true due to limited range of data type
client.c:589: warning: comparison is always true due to limited range of data type
client.c:589: warning: comparison is always true due to limited range of data type
client.c:594: warning: comparison is always true due to limited range of data type
client.c:594: warning: comparison is always true due to limited range of data type
client.c:599: warning: comparison is always true due to limited range of data type
client.c:599: warning: comparison is always true due to limited range of data type
client.c:604: warning: comparison is always true due to limited range of data type
client.c:604: warning: comparison is always true due to limited range of data type
client.c:608: warning: comparison is always true due to limited range of data type
client.c:608: warning: comparison is always true due to limited range of data type
client.c:613: warning: comparison is always true due to limited range of data type
client.c:613: warning: comparison is always true due to limited range of data type
client.c:618: warning: comparison is always true due to limited range of data type
client.c:618: warning: comparison is always true due to limited range of data type
client.c:622: warning: comparison is always true due to limited range of data type
client.c:622: warning: comparison is always true due to limited range of data type
client.c:627: warning: comparison is always true due to limited range of data type
client.c:627: warning: comparison is always true due to limited range of data type
client.c:632: warning: implicit conversion shortens 64-bit value into a 32-bit value
client.c:632: warning: comparison is always true due to limited range of data type
client.c:632: warning: comparison is always true due to limited range of data type
client.c:642: warning: implicit conversion shortens 64-bit value into a 32-bit value
client.c:642: warning: comparison is always true due to limited range of data type
client.c:642: warning: comparison is always true due to limited range of data type
client.c:647: warning: implicit conversion shortens 64-bit value into a 32-bit value
client.c:647: warning: comparison is always true due to limited range of data type
client.c:647: warning: comparison is always true due to limited range of data type
client.c:652: warning: implicit conversion shortens 64-bit value into a 32-bit value
client.c:652: warning: comparison is always true due to limited range of data type
client.c:652: warning: comparison is always true due to limited range of data type
client.c:657: warning: implicit conversion shortens 64-bit value into a 32-bit value
client.c:657: warning: comparison is always true due to limited range of data type
client.c:657: warning: comparison is always true due to limited range of data type
make: *** [client.o] Error 1
Gem files will remain installed in /Users/toddOld/.rvm/gems/ruby-1.9.2-p0/gems/mysql2-0.2.6 for inspection.
Results logged to /Users/toddO
ld/.rvm/gems/ruby-1.9.2-p0/gems/mysql2-0.2.6/ext/mysql2/gem_make.out
我尝试安装多个不同的 MySQL 版本,包括 5.5.6.rc、5.1.14 和 5.1.49。我正在运行安装了 XCode 工具的 Mac OS X 10.5.8。我确认 MySQL 从命令行运行并正确连接。
I am currently trying to install the mysql2 gem for a Ruby on Rails application. I am using Ruby 1.9.2. Here is the error:
todd-andrewss-macbook:shiftly toddOld$ gem install mysql2
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/Users/toddOld/.rvm/rubies/ruby-1.9.2-p0/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... yes
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
creating Makefile
make
gcc -I. -I/Users/toddOld/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/i386-darwin9.8.0 -I/Users/toddOld/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby/backward -I/Users/toddOld/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1 -I. -DHAVE_RB_THREAD_BLOCKING_REGION -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/usr/local/mysql/include -g -Os -arch x86_64 -fno-common -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL -fno-common -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long -fno-common -pipe -Wall -funroll-loops -o client.o -c client.c
In file included from /Users/toddOld/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby.h:32,
from ./mysql2_ext.h:4,
from client.c:1:
/Users/toddOld/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby/ruby.h:108: error: size of array ‘ruby_check_sizeof_long’ is negative
/Users/toddOld/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby/ruby.h:112: error: size of array ‘ruby_check_sizeof_voidp’ is negative
In file included from /Users/toddOld/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby/intern.h:29,
from /Users/toddOld/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby/ruby.h:1327,
from /Users/toddOld/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby.h:32,
from ./mysql2_ext.h:4,
from client.c:1:
/Users/toddOld/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby/st.h:69: error: size of array ‘st_check_for_sizeof_st_index_t’ is negative
client.c: In function ‘rb_raise_mysql2_error’:
client.c:79: warning: comparison is always true due to limited range of data type
client.c:79: warning: comparison is always true due to limited range of data type
client.c: In function ‘rb_mysql_client_socket’:
client.c:412: warning: comparison is always true due to limited range of data type
client.c:412: warning: comparison is always true due to limited range of data type
client.c: In function ‘init_mysql2_client’:
client.c:556: warning: comparison is always true due to limited range of data type
client.c:556: warning: comparison is always true due to limited range of data type
client.c:561: warning: comparison is always true due to limited range of data type
client.c:561: warning: comparison is always true due to limited range of data type
client.c:566: warning: comparison is always true due to limited range of data type
client.c:566: warning: comparison is always true due to limited range of data type
client.c:571: warning: comparison is always true due to limited range of data type
client.c:571: warning: comparison is always true due to limited range of data type
client.c:576: warning: comparison is always true due to limited range of data type
client.c:576: warning: comparison is always true due to limited range of data type
client.c:580: warning: comparison is always true due to limited range of data type
client.c:580: warning: comparison is always true due to limited range of data type
client.c:584: warning: comparison is always true due to limited range of data type
client.c:584: warning: comparison is always true due to limited range of data type
client.c:589: warning: comparison is always true due to limited range of data type
client.c:589: warning: comparison is always true due to limited range of data type
client.c:594: warning: comparison is always true due to limited range of data type
client.c:594: warning: comparison is always true due to limited range of data type
client.c:599: warning: comparison is always true due to limited range of data type
client.c:599: warning: comparison is always true due to limited range of data type
client.c:604: warning: comparison is always true due to limited range of data type
client.c:604: warning: comparison is always true due to limited range of data type
client.c:608: warning: comparison is always true due to limited range of data type
client.c:608: warning: comparison is always true due to limited range of data type
client.c:613: warning: comparison is always true due to limited range of data type
client.c:613: warning: comparison is always true due to limited range of data type
client.c:618: warning: comparison is always true due to limited range of data type
client.c:618: warning: comparison is always true due to limited range of data type
client.c:622: warning: comparison is always true due to limited range of data type
client.c:622: warning: comparison is always true due to limited range of data type
client.c:627: warning: comparison is always true due to limited range of data type
client.c:627: warning: comparison is always true due to limited range of data type
client.c:632: warning: implicit conversion shortens 64-bit value into a 32-bit value
client.c:632: warning: comparison is always true due to limited range of data type
client.c:632: warning: comparison is always true due to limited range of data type
client.c:642: warning: implicit conversion shortens 64-bit value into a 32-bit value
client.c:642: warning: comparison is always true due to limited range of data type
client.c:642: warning: comparison is always true due to limited range of data type
client.c:647: warning: implicit conversion shortens 64-bit value into a 32-bit value
client.c:647: warning: comparison is always true due to limited range of data type
client.c:647: warning: comparison is always true due to limited range of data type
client.c:652: warning: implicit conversion shortens 64-bit value into a 32-bit value
client.c:652: warning: comparison is always true due to limited range of data type
client.c:652: warning: comparison is always true due to limited range of data type
client.c:657: warning: implicit conversion shortens 64-bit value into a 32-bit value
client.c:657: warning: comparison is always true due to limited range of data type
client.c:657: warning: comparison is always true due to limited range of data type
make: *** [client.o] Error 1
Gem files will remain installed in /Users/toddOld/.rvm/gems/ruby-1.9.2-p0/gems/mysql2-0.2.6 for inspection.
Results logged to /Users/toddO
ld/.rvm/gems/ruby-1.9.2-p0/gems/mysql2-0.2.6/ext/mysql2/gem_make.out
I tried installing with a number of different MySQL versions, including 5.5.6.rc, 5.1.14 and 5.1.49. I am running Mac OS X 10.5.8 with the XCode tools installed. I confirmed that MySQL works from the command line and connects correctly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查您的 Ruby 版本。如果是 64 位,那么您的 MySQL 也需要是 64 位,反之亦然。
同样根据安装使用
archflags
进行安装,并添加--no-ri
和--no-rdoc
。Check your Ruby version. If it's 64-bit then your MySQL needs to be 64-bit and vice versa.
Also install with
archflags
according to the installation and add--no-ri
and--no-rdoc
.