安装Wit gem会导致模糊的Ruby错误

时间:2014-12-04 08:50:45

标签: ruby-on-rails ruby

我创建了一个全新的Rails应用程序并将gem wit添加到Gemfile中。现在,当我运行bundle install时,我收到此错误。在谷歌寻找解决方案时,我遇到了四种不同的可能性,但它们都不适用于我的开发环境(OSX 10.9.5,Brew 0.9.5)。有人解决了这个问题吗?

链接:

The compiler failed to generate an executable file. (RuntimeError)

https://github.com/CocoaPods/CocoaPods/issues/1727

https://github.com/copiousfreetime/hitimes/issues/26

https://teamtreehouse.com/forum/rails-gem-wont-install-properly

...
Using turbolinks 2.5.2
Using uglifier 2.5.3

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /Users/user/.rvm/rubies/ruby-2.1-head/bin/ruby -r ./siteconf20141204-96223-d2ceuv.rb extconf.rb 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 12.7M  100 12.7M    0     0   741k      0  0:00:17  0:00:17 --:--:--  723k
checking for main() in -lsox... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
  --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/user/.rvm/rubies/ruby-2.1-head/bin/ruby
  --with-wit-dir
  --without-wit-dir
  --with-wit-include
  --without-wit-include=${wit-dir}/include
  --with-wit-lib
  --without-wit-lib=${wit-dir}/lib
  --with-soxlib
  --without-soxlib
/Users/user/.rvm/rubies/ruby-2.1-head/lib/ruby/2.1.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
  from /Users/user/.rvm/rubies/ruby-2.1-head/lib/ruby/2.1.0/mkmf.rb:541:in `try_link0'
  from /Users/user/.rvm/rubies/ruby-2.1-head/lib/ruby/2.1.0/mkmf.rb:556:in `try_link'
  from /Users/user/.rvm/rubies/ruby-2.1-head/lib/ruby/2.1.0/mkmf.rb:742:in `try_func'
  from /Users/user/.rvm/rubies/ruby-2.1-head/lib/ruby/2.1.0/mkmf.rb:973:in `block in have_library'
  from /Users/user/.rvm/rubies/ruby-2.1-head/lib/ruby/2.1.0/mkmf.rb:918:in `block in checking_for'
  from /Users/user/.rvm/rubies/ruby-2.1-head/lib/ruby/2.1.0/mkmf.rb:351:in `block (2 levels) in postpone'
  from /Users/user/.rvm/rubies/ruby-2.1-head/lib/ruby/2.1.0/mkmf.rb:321:in `open'
  from /Users/user/.rvm/rubies/ruby-2.1-head/lib/ruby/2.1.0/mkmf.rb:351:in `block in postpone'
  from /Users/user/.rvm/rubies/ruby-2.1-head/lib/ruby/2.1.0/mkmf.rb:321:in `open'
  from /Users/user/.rvm/rubies/ruby-2.1-head/lib/ruby/2.1.0/mkmf.rb:347:in `postpone'
  from /Users/user/.rvm/rubies/ruby-2.1-head/lib/ruby/2.1.0/mkmf.rb:917:in `checking_for'
  from /Users/user/.rvm/rubies/ruby-2.1-head/lib/ruby/2.1.0/mkmf.rb:968:in `have_library'
  from extconf.rb:33:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /Users/user/.rvm/gems/ruby-2.1-head/gems/wit-1.0.5 for inspection.
Results logged to /Users/user/.rvm/gems/ruby-2.1-head/extensions/x86_64-darwin-13/2.1.0/wit-1.0.5/gem_make.out
An error occurred while installing wit (1.0.5), and Bundler cannot continue.
Make sure that `gem install wit -v '1.0.5'` succeeds before bundling.

以下是mkmf.log

的输出
$ cat /Users/user/.rvm/gems/ruby-2.1-head/extensions/x86_64-darwin-13/2.1.0/wit-1.0.5/mkmf.log
"/usr/bin/clang -o conftest -I/Users/user/.rvm/rubies/ruby-2.1-head/include/ruby-2.1.0/x86_64-darwin13.0 -I/Users/user/.rvm/rubies/ruby-2.1-head/include/ruby-2.1.0/ruby/backward -I/Users/user/.rvm/rubies/ruby-2.1-head/include/ruby-2.1.0 -I. -I/Users/user/.rvm/gems/ruby-2.1-head/gems/wit-1.0.5/ext/wit/libwit/include -I/Users/user/.rvm/rubies/ruby-2.1-head/include  -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wextra-tokens  -fno-common -pipe conftest.c  -L. -L/Users/user/.rvm/rubies/ruby-2.1-head/lib -L/Users/user/.rvm/gems/ruby-2.1-head/gems/wit-1.0.5/ext/wit/libwit/lib -L/Users/user/.rvm/rubies/ruby-2.1-head/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib    -lwit -lsox -lcurl  -lruby.2.1.0  -lpthread -lgmp -ldl -lobjc "
ld: library not found for -lsox
clang: error: linker command failed with exit code 1 (use -v to see invocation)
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

1 个答案:

答案 0 :(得分:0)

我通过重新安装X-Code的命令行工具解决了这个问题:xcode-install --select