我们的实习生的计算机在安装mysql2 gem时遇到问题。我们刚刚将他的计算机从OS X 10.6升级到10.8(Mountain Lion)。我尝试通过自制软件和64位DMG安装程序安装mysql。我也尝试了symlink到dev工具(正如这里指出的那样:Not able to install some gems after mountain lion upgrade)。我们安装了Xcode(4.4)并安装了命令行工具。我们在安装命令行工具后尝试重新启动。
这是来自~/.bashrc
的他的PATH声明:
PATH=/usr/local/bin:$PATH:$HOME/.rvm/bin:/usr/local/mysql/bin # Add RVM to PATH for scripting
符号链接:
Diego-Blantons-MacBook-Pro-3:~ lmrunner07$ sudo ln -s /usr/bin/llvm-gcc-4.2 /usr/bin/gcc-4.2
Password:
尝试安装gem:
Diego-Blantons-MacBook-Pro-3:~ lmrunner07$ gem install mysql2
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/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 /Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby.h:32,
from ./mysql2_ext.h:8,
from client.c:1:
/Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/ruby.h:105: error: size of array ‘ruby_check_sizeof_long’ is negative
/Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/ruby.h:109: error: size of array ‘ruby_check_sizeof_voidp’ is negative
In file included from /Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/intern.h:34,
from /Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/ruby.h:1382,
from /Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby.h:32,
from ./mysql2_ext.h:8,
from client.c:1:
/Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/st.h:67: error: size of array ‘st_check_for_sizeof_st_index_t’ is negative
client.c: In function ‘rb_raise_mysql2_error’:
client.c:98: warning: ISO C90 forbids mixed declarations and code
client.c: In function ‘rb_mysql_client_socket’:
client.c:590: warning: ISO C90 forbids mixed declarations and code
make: *** [client.o] Error 1
Gem files will remain installed in /Users/lmrunner07/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11 for inspection.
Results logged to /Users/lmrunner07/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/ext/mysql2/gem_make.out
我已经删除了自制软件安装的mysql以及启动代理。另外rm -rf
gem目录(Users / lmrunner07 / .rvm / gems / ruby-1.9.3-p194 / gems / mysql2-0.3.11)
答案 0 :(得分:5)
我通过以下方式解决了这个问题:
ruby <(curl -fsSk https://raw.github.com/mxcl/homebrew/go)
(查看他们的网站使用http://mxcl.github.com/homebrew/)brew install mysql
重新安装mysql。 (我尝试按照这些说明http://erictarn.com/post/28269453881/how-i-installed-mysql-rvm-ruby-and-rails-on-mountain安装mysql但我后来遇到了问题所以我建议用自制软件重新安装mysql。)注意:当我尝试构建时遇到了库问题Library not loaded: libmysqlclient.18.dylib
,该问题已通过运行sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
修复(如果您遇到同样的问题,请参阅Library not loaded: libmysqlclient.16.dylib error when trying to run 'rails server' on OS X 10.6 with mysql2 gem。)
答案 1 :(得分:0)
你试过了吗?
gem install mysql2 --with-mysql-config=/usr/lib64/mysql/mysql_config
将/usr/lib64/mysql/mysql_config
替换为mysql配置的位置。
答案 2 :(得分:0)
不幸的是,安装过程非常细分,如果不仔细查看整体步骤,很难找出问题所在。
在不了解您的安装步骤的情况下,以下是我所遵循的一些注释,这些注释让我进入了一个稳定的Rails Mountain Lion开发框(再次,道歉,这不是更具体)。
RVM指令,Ruby:moncefbelyamani.com
注意:我在这里采取的措施肯定来自brew doctor
和'rvm requirements'
的建议,我从未在以前的设置中采用过。
注意:
brew install autoconf automake apple-gcc42
brew tap homebrew/dupes
Rails特定说明:railsapps.github.com
注意:我执行了可选步骤: ...为了使用mysql命令而不输入将mysql目录添加到shell路径所需的命令的完整路径... < strong>正如我发现这样做可以在构建期间提供帮助等(某些脚本假设......)
在这里,我尝试简单地创建一个新的rails应用程序,默认数据库是mysql(通过bundler将mysql2降级)。从那里 - 我尝试用快速脚手架做一个测试应用程序 - 和mysql2 barfed。
从那里我发现了一个错误'Library not loaded:libmysqlclient.16.dylib',如下所示:stackoverflow awesomeness
我将此行添加到我的.profile:export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH
MY PATH明确包含了rails和ruby: /Users/gabriel/.rvm/gems/ruby-1.9.3-p194@rails327/bin:/Users/gabriel/.rvm/gems/ruby-1.9.3-p194@global/bin:/Users/gabriel/.rvm/rubies/ruby-1.9.3-p194/bin:/Users/gabriel/.rvm/bin:/usr/local/mysql/bin:/usr/local/bin:/usr/bin:/usr/sbin:/opt/X11/bin:
希望这些资源能提供一些额外的帮助。
答案 3 :(得分:0)
我能够通过运行来编译它: PATH = / bin:/ usr / bin:/ opt / mysql5_64 / bin gem install mysql2 哪里有mysql5_64我下载了最新的64位版本的mysql并在那里提取。保留已安装的mysql数据库。
答案 4 :(得分:0)
我能够通过implode
- rvm和安装Homebrew的ruby来解决这个问题。然后,安装mysql2 gem就好了。
这不是我遇到过rvm这样的第一个问题。我不认为我会再次使用它。
答案 5 :(得分:0)
我在OSX Yosemite上成功完成了这项工作:
sudo port install mysql56
gem install mysql2 -- --with-mysql-config=/opt/local/lib/mysql56/bin/mysql_config