rvm install 1.9.3导致ImageMagick安装问题

时间:2013-06-23 20:01:50

标签: ruby-on-rails rvm rmagick

我使用Ruby 1.9.2作为我的RoR 3.2.11项目

所有工作正常,直到我不得不升级到Ruby 1.9.3,因为宝石需要它。 在同一场合,我试图充分利用RVM。

安装ruby 1.9.3

rvm install 1.9.3 -C --with-openssl-dir=$HOME/.rvm/usr

创建.rvmrc

cd ./my_project/
rvm --create --rvmrc 1.9.3@project

清理我的全球宝石

rvm gemset empty

进入我的项目并运行已安装的gems

bundle

错误日志

Installing rmagick (2.13.2) 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /Users/joel/.rvm/rubies/ruby-1.9.3-p429/bin/ruby extconf.rb 
checking for Ruby version >= 1.8.5... yes
checking for /opt/local/bin/gcc-apple-4.2... yes
checking for Magick-config... yes

Warning: Found more than one ImageMagick installation. This could cause problems at runtime.
         /usr/local/ImageMagick/bin/Magick-config reports version 6.7.3 Q16 is installed in 
         /usr/local/bin/Magick-config reports version 6.7.1 Q16 is installed in /usr/local/Cellar/imagemagick/6.7.1-1
Using 6.7.3 Q16 from .

checking for ImageMagick version >= 6.4.9... yes
checking for HDRI disabled version of ImageMagick... 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
    --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/joel/.rvm/rubies/ruby-1.9.3-p429/bin/ruby
/Users/joel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /Users/joel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp'
    from /Users/joel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:931:in `block in have_header'
    from /Users/joel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
    from /Users/joel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
    from /Users/joel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /Users/joel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
    from /Users/joel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /Users/joel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
    from /Users/joel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
    from /Users/joel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:930:in `have_header'
    from extconf.rb:194:in `<main>'


Gem files will remain installed in /Users/joel/.rvm/gems/ruby-1.9.3-p429@creativebank/gems/rmagick-2.13.2 for inspection.
Results logged to /Users/joel/.rvm/gems/ruby-1.9.3-p429@my_project/gems/rmagick-2.13.2/ext/RMagick/gem_make.out

An error occurred while installing rmagick (2.13.2), and Bundler cannot continue.
Make sure that `gem install rmagick -v '2.13.2'` succeeds before bundling.

乍一看,看起来我有2个ImageMagick安装,我可以省一个。

所以我的第一个问题是如何卸载干净的ImageMagick版本6.7.1 Q16?

当然,如果还有别的东西,我可以尝试解决这个问题。

关于已安装软件包的附加信息

我知道MacPort和Brew不能很好地协同工作,但我一直担心完全删除MacPort。这可能是问题吗?

port list | grep magick

p5-perlmagick                  @6.8.6-0        perl/p5-perlmagick
p5.8-perlmagick                @6.8.6-0        perl/p5-perlmagick
p5.10-perlmagick               @6.8.6-0        perl/p5-perlmagick
p5.12-perlmagick               @6.8.6-0        perl/p5-perlmagick
p5.14-perlmagick               @6.8.6-0        perl/p5-perlmagick
p5.16-perlmagick               @6.8.6-0        perl/p5-perlmagick
php-gmagick                    @1.1.2RC1       php/php-gmagick
php53-gmagick                  @1.1.2RC1       php/php-gmagick
php54-gmagick                  @1.1.2RC1       php/php-gmagick
php55-gmagick                  @1.1.2RC1       php/php-gmagick
php-imagick                    @3.1.0RC2       php/php-imagick
php53-imagick                  @3.1.0RC2       php/php-imagick
php54-imagick                  @3.1.0RC2       php/php-imagick
php55-imagick                  @3.1.0RC2       php/php-imagick
php-magickwand                 @1.0.9-2        php/php-magickwand
php53-magickwand               @1.0.9-2        php/php-magickwand
php54-magickwand               @1.0.9-2        php/php-magickwand
php55-magickwand               @1.0.9-2        php/php-magickwand
php5-gmagick                   @1.1.2RC1       php/php5-gmagick
php5-imagick                   @3.0.1          php/php5-imagick
php5-magickwand                @1.0.9-2        php/php5-magickwand
rb-rmagick                     @2.13.2         ruby/rb-rmagick


brew list

faac        grc     jasper      lame        libtiff     libvpx      pkg-config  wget        xvid
ffmpeg      imagemagick jpeg        libogg      libvorbis   little-cms  theora      x264        yasm

更新

删除MacPorts

sudo port -f uninstall installed

卸载brew ImageMagick并使用brew再次安装

已安装XCode最新版本

并运行bundle,我确实得到了一个不同的消息,C编译器丢失了...唉,我接下来该怎么办,我正在尝试用brew安装gcc,但不确定我是朝着正确的方向前进,请帮忙:

Installing rmagick (2.13.2) 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /Users/joel/.rvm/rubies/ruby-1.9.3-p429/bin/ruby extconf.rb 
checking for Ruby version >= 1.8.5... yes
checking for /opt/local/bin/gcc-apple-4.2... no
No C compiler found in ${ENV['PATH']}. See mkmf.log for details.
*** 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/joel/.rvm/rubies/ruby-1.9.3-p429/bin/ruby


Gem files will remain installed in /Users/joel/.rvm/gems/ruby-1.9.3-p429@creativebank/gems/rmagick-2.13.2 for inspection.
Results logged to /Users/joel/.rvm/gems/ruby-1.9.3-p429@creativebank/gems/rmagick-2.13.2/ext/RMagick/gem_make.out

An error occurred while installing rmagick (2.13.2), and Bundler cannot continue.
Make sure that `gem install rmagick -v '2.13.2'` succeeds before bundling.

GCC 4.2

which gcc => /usr/bin/gcc

gcc -v

Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.11~182/src/configure --disable-checking --enable-werror --prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.11~182/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)

echo $ PATH

   /bin;/usr/bin;/usr/sbin;/sbin;/usr/local/ImageMagick/bin:/usr/local/heroku/bin:/Applications/Postgres.app/Contents/MacOS/bin:/Users/joel/.rvm/gems/ruby-1.9.3-p429@biowatts/bin:/Users/joel/.rvm/gems/ruby-1.9.3-p429@global/bin:/Users/joel/.rvm/rubies/ruby-1.9.3-p429/bin:/Users/joel/.rvm/bin:/usr/bin;usr/local/ImageMagick/bin:/usr/local/heroku/bin:/Applications/Postgres.app/Contents/MacOS/bin:/usr/local/ImageMagick/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Users/joel

新的错误消息:

Installing json (1.8.0) 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /Users/joel/.rvm/rubies/ruby-1.9.3-p429/bin/ruby extconf.rb 
creating Makefile

make
compiling generator.c
make: /opt/local/bin/gcc-apple-4.2: No such file or directory
make: *** [generator.o] Error 1


Gem files will remain installed in /Users/joel/.rvm/gems/ruby-1.9.3-p429@biowatts/gems/json-1.8.0 for inspection.
Results logged to /Users/joel/.rvm/gems/ruby-1.9.3-p429@biowatts/gems/json-1.8.0/ext/json/ext/generator/gem_make.out

它显然正在寻找/opt/local/bin/gcc-apple-4.2,我在按照这些说明move from Macportd to homebrew时罔顾后果地删除了:(

现在用自制软件安装丢失的包

brew install apple-gcc42 brew install libxml2

3 个答案:

答案 0 :(得分:1)

夫妻俩:

  1. 删除MacPorts(您可以列出随它们安装的所有内容并重新安装brew)
  2. 从自制程序中删除imagemagick
  3. 使用brew
  4. 再次安装imagemagick

    您收到此错误You have to install development tools first.,我猜这意味着您需要安装XCode命令行工具。

    然后bundle install应该有效!

答案 1 :(得分:1)

删除用于安装它的软件包管理器后,您需要重新安装ruby,最简单的方法是:

rvm reinstall 1.9.3-p429

答案 2 :(得分:0)

结合2个第一个答案

brew uninstall imagemagick

并使用http://cactuslab.com/imagemagick/

然后在我的.bash_profile中设置

PKG_CONFIG_PATH=/opt/ImageMagick/lib/pkgconfig 
C_INCLUDE_PATH=/opt/ImageMagick/include/ImageMagick-6 

最后

bundle