几天前我升级到El Capitan然后跑了一个
brew update && brew upgrade
它更新了imagemagick,导致ruby的rmagick gem停止工作.
没问题,我想,我会跑
gem install rmagick
它会重新编译.
除了它没有,当我运行它时,我看到:
gem install rmagick Building native extensions. This could take a while... ERROR: Error installing rmagick: ERROR: Failed to build gem native extension. /Users/sam/.rbenv/versions/2.2.3/bin/ruby -r ./siteconf20151019-57347-30ju1w.rb extconf.rb checking for clang... yes checking for Magick-config... yes checking for outdated ImageMagick version (<= 6.4.9)... no checking for Ruby version >= 1.8.5... yes checking for stdint.h... *** 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 --without-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/sam/.rbenv/versions/2.2.3/bin/$(RUBY_BASE_NAME) /Users/sam/.rbenv/versions/2.2.3/lib/ruby/2.2.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/sam/.rbenv/versions/2.2.3/lib/ruby/2.2.0/mkmf.rb:587:in `try_cpp' from /Users/sam/.rbenv/versions/2.2.3/lib/ruby/2.2.0/mkmf.rb:1060:in `block in have_header' from /Users/sam/.rbenv/versions/2.2.3/lib/ruby/2.2.0/mkmf.rb:911:in `block in checking_for' from /Users/sam/.rbenv/versions/2.2.3/lib/ruby/2.2.0/mkmf.rb:351:in `block (2 levels) in postpone' from /Users/sam/.rbenv/versions/2.2.3/lib/ruby/2.2.0/mkmf.rb:321:in `open' from /Users/sam/.rbenv/versions/2.2.3/lib/ruby/2.2.0/mkmf.rb:351:in `block in postpone' from /Users/sam/.rbenv/versions/2.2.3/lib/ruby/2.2.0/mkmf.rb:321:in `open' from /Users/sam/.rbenv/versions/2.2.3/lib/ruby/2.2.0/mkmf.rb:347:in `postpone' from /Users/sam/.rbenv/versions/2.2.3/lib/ruby/2.2.0/mkmf.rb:910:in `checking_for' from /Users/sam/.rbenv/versions/2.2.3/lib/ruby/2.2.0/mkmf.rb:1059:in `have_header' from extconf.rb:38:in `configure_headers' from extconf.rb:18:in `initialize' from extconf.rb:517:in `new' from extconf.rb:517:in `<main>' extconf Failed,exit code 1 Gem files will remain installed in /Users/sam/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rmagick-2.15.4 for inspection. Results logged to /Users/sam/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0-static/rmagick-2.15.4/gem_make.out
这是mkmf.log的内容
find_executable: checking for clang... -------------------- yes -------------------- find_executable: checking for Magick-config... -------------------- yes -------------------- configure_compile_options: checking for outdated ImageMagick version (<= 6.4.9)... -------------------- no Detected ImageMagick version: 6.9.2 -------------------- assert_minimum_ruby_version!: checking for Ruby version >= 1.8.5... -------------------- yes -------------------- "clang -o conftest -I/Users/sam/.rbenv/versions/2.2.3/include/ruby-2.2.0/x86_64-darwin14 -I/Users/sam/.rbenv/versions/2.2.3/include/ruby-2.2.0/ruby/backward -I/Users/sam/.rbenv/versions/2.2.3/include/ruby-2.2.0 -I. -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 conftest.c -L. -L/Users/sam/.rbenv/versions/2.2.3/lib -L/usr/local/Cellar/imagemagick/6.9.2-4/lib -lMagickCore-6.Q16 -L/usr/local/Cellar/imagemagick/6.9.2-4/lib -lMagickCore-6.Q16 -lruby-static -framework CoreFoundation -lpthread -lgmp -ldl -lobjc " ld: library not found for -lgmp 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 */
有任何想法吗?
解决方法
固定它.
运行的神奇命令是这样的:
xcode-select --install