2012-07-27 143 views
7

我们实习生的电脑在安装mysql2 gem时遇到问题。我们只是将他的电脑从OS X 10.6升级到了10.8(Mountain Lion)。我曾尝试通过自制软件和64位DMG安装程序安装MySQL。我也尝试了对开发工具的符号链接(正如这里指出的:Not able to install some gems after mountain lion upgrade)。我们安装了Xcode(4.4)并安装了命令行工具。我们在安装命令行工具后尝试重新启动。mysql2 gem无法构建原生扩展

这是~/.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: 

尝试安装宝石:

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宝石目录(用户/ lmrunner07/.rvm /宝石/红宝石1.9.3-P194 /宝石/ mysql2-0.3.11)

+0

您可以验证您的Xcode 4.4版本是重新发布两个狮子和山狮? – davidcelis 2012-07-27 18:21:06

+0

对不起,您想要我检查什么? – 2012-07-27 18:36:38

+0

当Mountain Lion发布时,他们更新了应用商店中的Xcode 4.4,使其成为兼容Lion和Mountain Lion的版本。如果你没有重新安装Xcode,很可能你的版本只与以前版本的OS X兼容。 – davidcelis 2012-07-27 18:43:53

回答

5

我解决了这个由:

  1. 安装自制ruby <(curl -fsSk https://raw.github.com/mxcl/homebrew/go) (看看他们的使用率http://mxcl.github.com/homebrew/网站)
  2. 按照这些指令http://robots.thoughtbot.com/post/27985816073/the-hitchhikers-guide-to-riding-a-mountain-lion
  3. 重新安装的MySQL与自制brew install mysql。 (我试图按照这些指示http://erictarn.com/post/28269453881/how-i-installed-mysql-rvm-ruby-and-rails-on-mountain安装MySQL,但我遇到了问题以后,所以我会建议重新安装的MySQL与自制。)
  4. 重新安装RVM和轨和我的项目宝石(其中包括mysql2)

注:(参见Library not loaded: libmysqlclient.16.dylib error when trying to run 'rails server' on OS X 10.6 with mysql2 gem如果你得到了同样的问题)当我试图建立我有一个图书馆的问题,Library not loaded: libmysqlclient.18.dylib,这是固定的运行sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib

+0

实习生今天不在,所以我无法尝试。如果如果有效,我会回来点。感谢您的链接 – 2012-08-06 17:15:07

+0

第2步中的链接做到了。不知道哪一步做到了,但谢谢! – 2012-08-07 17:20:15

+0

不用担心。谢谢你的观点。我很高兴它的工作。花了好几个小时才自己解决。我以为我应该分享。 – Harro 2012-08-07 19:50:45

0

你试过:

gem install mysql2 --with-mysql-config=/usr/lib64/mysql/mysql_config 

更换/usr/lib64/mysql/mysql_config用你的mysql配置的位置。

+0

我想这个命令是:'gem install mysql2 - --with-mysql-config =/usr/lib64/mysql/mysql_config'?(额外' - ')得到了相同的结果,虽然 – 2012-07-27 18:46:58

0

不幸的是,安装过程是非常细分化的,如果没有全面查看您的步骤,很难隔离您的问题。

不知道更多关于你的安装步骤,这里有一些我注意到的事情让我看到了一个稳定的Rails Mountain Lion开发框(同样道歉,这不是更具体)。

  1. 说明RVM,红宝石:moncefbelyamani.com

    注:有一定的步骤在这里,我通过了建议从brew doctor'rvm requirements'我从来没有在以前的设置拍摄。

    注意事项,如:

    • 的Xcode 4.3或更高版本仅使用Ruby-1.9.3-P125 +(并告诉我,如果我有编译问题降级到的Xcode 4.1)
    • 使用brew install autoconf automake apple-gcc42
    • 使用brew tap homebrew/dupes
    • 和别人...
  2. 个Rails的具体说明:railsapps.github.com

  3. 为MySQL(跳到下安装的MySQL的部分:coolestguyplanettech.com

注:我做了可选步骤: ...为了使用而无需键入命令的MySQL您需要将mysql目录添加到shell路径的命令的完整路径...,因为我发现这样做可以帮助在构建等(一些脚本假设...)

在这里,我试图简单地创建一个新的rails应用程序与默认数据库是mysql(这将关闭mysql2通过捆绑)。从那里 - 我试图做一个快速脚手架测试应用程序 - 和mysql2 barfed。

从那里我遇到错误“库未加载:libmysqlclient.16.dylib”和这里要注意:stackoverflow awesomeness 我加入这行到我的.profile文件:export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH

我的道路包括轨道和红宝石明确:/Users/gabriel/.rvm/gems/[email protected]/bin:/Users/gabriel/.rvm/gems/[email protected]/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:

希望这些资源能提供一些额外的帮助。

+0

实习生今天出去了,所以我不能试试这个。如果如果有效,我会回来点。感谢您的链接 – 2012-08-06 17:14:43

0

我能得到它的运行编译: PATH =/bin:/ usr/bin:/ opt/mysql5_64/bin gem install mysql2 W这里mysql5_64我下载了最新的64位版本的mysql并在那里提取。离开我已经安装的mysql数据库。

0

我能通过implode -ing rvm解决这个问题并安装Homebrew的红宝石。然后,mysql2 gem安装就好了。

这不是像我遇到过的第一个问题。我不认为我会再次使用它。

0

我有这个在OSX约塞米蒂成功运行:

sudo port install mysql56 
gem install mysql2 -- --with-mysql-config=/opt/local/lib/mysql56/bin/mysql_config 
相关问题