繁体   English   中英

ruby1.9.3上的宝石mysql2安装错误

[英]Gem mysql2 installation error on ruby1.9.3

刚刚更新到macOS Mojave,通过brew重新安装了mysql,并下载了最新的xcode 9.2。 在尝试为旧的Rails项目设置开发环境时,捆绑程序在安装mysql2 gem时崩溃。 在开始时,我认为这是因为最新的mysql2版本与ruby 1.9不兼容,所以我尝试了:

gem安装mysql2 -v'0.3.17'

我收到了:

/Users/me/.rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb检查ruby / thread.h ... * extconf.rb失败*由于某些原因,无法创建Makefile缺少必要的库和/或头。 检查mkmf.log文件以获取更多详细信息。 您可能需要配置选项。

提供的配置选项:--with-opt-dir --with-opt-include --without-opt-include = $ {opt-dir} / include --with-opt-lib --without-opt-lib = $ {opt-dir} / lib --with-make-prog --without-make-prog --srcdir =。 --curdir --ruby = / Users / me / .rvm / rubies / ruby​​-1.9.3-p125 / bin / ruby​​ /Users/me/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/ 1.9.1 / mkmf.rb:381:在try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /Users/me/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:506:in try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /Users/me/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:506:in try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /Users/me/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:506:in /Users/me/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:506:在try_cpp中.3-p125 / lib / ruby​​ / 1.9.1 / mkmf.rb:931:在block in have_header' from /Users/me/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:790:inblock in have_header' from /Users/me/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:790:inblock (2 levels) in postpone' from /Users/me/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:254:in open'from /Users/me/.rvm/rubies /ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:284 block in postpone' from /Users/me/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:254:in open'from /Users/me/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:280:in postpone' from /Users/me/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:789:in的/Users/me/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:789:in .3-p125 / lib / ruby​​ / 1.9.1 / mkmf.rb:930:in have_header' from extconf.rb:9:in '

从/Users/me/.rvm/gems/ruby-1.9.3-p125@mailcatcher/gems/mysql2-0.2.18/ext/mysql2/mkmf.log复制:

“ /usr/bin/gcc-4.2 -o conftest -I / Users / me / .rvm / rubies / ruby​​-1.9.3-p125 / include / ruby​​-1.9.1 / x86_64-darwin10.8.0 -I / Users /我/.rvm/红宝石/红宝石1.9.3-p125 / include /红宝石1.9.1 /红宝石/后退-I / Users / me / .rvm /红宝石/红宝石1.9.3-p125 / include /红宝石- 1.9.1 -I。-I / Users / me / .rvm / usr / include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -O3 -ggdb -Wextra -Wno未使用参数-Wno括号-Wno-long-long -Wno-missing-字段初始化程序-Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -fno-common -pipe conftest.c -L。-L / Users / me / .rvm / rubies / ruby​​-1.9.3-p125 / lib -L ​​/ Users / me / .rvm / usr / lib -L。-L / usr / local / lib -lruby.1.9.1 -lpthread -ldl -lobjc “已检查的程序为:/ *开始/ 1:#include“ ruby​​.h” 2:3:int main(){返回0;} /结束* /

听起来您好像缺少XCode命令行工具: xcode-select --install

或mySQL软件包:如果您还没有自制软件: $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"然后安装mysql: brew install mysql

我不记得过去曾为我解决过这个问题,但我敢肯定那是其中之一。

将我的答案与几乎完全相同的问题交叉链接。 我认为可能只是找不到正确的配置路径

sudo gem install mysql2 -- --with-mysql-config=/usr/local/bin/mysql_config

这里查看答案

编辑:格式化

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM