0

我在我的 RoR 3.2.11 项目中使用 Ruby 1.9.2

一切正常,直到我不得不升级到 Ruby 1.9.3,因为 gem 需要它。在同一场合,我尝试充分利用 RVM。

安装红宝石 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

清理了我的全局 gemset

rvm gemset empty

cd 进入我的项目并运行已安装的 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

更新

删除 Mac 端口

sudo port -f uninstall installed

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

安装 XCode 最新版本

并运行捆绑包,我确实收到了不同的消息,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.

海合会 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)

回声 $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 ,我在按照这些说明从 Macportd 迁移到 homebrew时鲁莽地删除了它 :(

现在用自制软件安装缺少的软件包

冲泡安装苹果-gcc42 冲泡安装libxml2

4

3 回答 3

1

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

rvm reinstall 1.9.3-p429
于 2013-06-24T18:02:57.727 回答
1

几件事:

  1. 删除 MacPorts(你可以列出所有你用它们安装的东西,然后用 brew 重新安装)
  2. 从自制软件中删除 imagemagick
  3. 使用 brew 再次安装 imagemagick

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

然后bundle install应该工作!

于 2013-06-23T20:49:18.580 回答
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
于 2013-06-25T15:46:21.103 回答