无法加载带有本机扩展的 gem:fresh 10.8、xcode 4.5、rvm

Posted

技术标签:

【中文标题】无法加载带有本机扩展的 gem:fresh 10.8、xcode 4.5、rvm【英文标题】:failing to load gem with native extensions: fresh 10.8, xcode 4.5, rvm 【发布时间】:2013-01-12 04:16:00 【问题描述】:
    清洁 Mountain Lion 安装 从应用商店安装了 XCode 4.5 安装了命令行工具 已安装 Home brew 酿酒医生很开心 已安装 RVM rvm 安装 1.9.3 安装程序要求更多 brews,安装了以下内容:
      苹果-gcc42 自动配置 自动制作 libksba

安装完成,一切正常...

maximus:~$ gem install json
Building native extensions.  This could take a while...
ERROR:  Error installing json:
  ERROR: Failed to build gem native extension.

        /Users/mmoser/.rvm/rubies/ruby-1.9.3-p362/bin/ruby extconf.rb
creating Makefile

make
compiling generator.c
generator.c:369: warning: unused parameter ‘self’
generator.c:423: warning: unused parameter ‘self’
generator.c:759: warning: unused parameter ‘Vstate’
generator.c:773: warning: unused parameter ‘Vstate’
generator.c:773: warning: unused parameter ‘state’
generator.c:773: warning: unused parameter ‘obj’
generator.c:778: warning: unused parameter ‘Vstate’
generator.c:778: warning: unused parameter ‘state’
generator.c:778: warning: unused parameter ‘obj’
generator.c:783: warning: unused parameter ‘Vstate’
generator.c:783: warning: unused parameter ‘state’
generator.c:783: warning: unused parameter ‘obj’
generator.c:788: warning: unused parameter ‘Vstate’
generator.c:788: warning: unused parameter ‘state’
generator.c:793: warning: unused parameter ‘Vstate’
generator.c:793: warning: unused parameter ‘state’
generator.c:799: warning: unused parameter ‘Vstate’
linking shared-object json/ext/generator.bundle

make install
/Users/mmoser/.rvm/scripts/install -c -m 0755 generator.bundle /Users/mmoser/.rvm/gems/ruby-1.9.3-p362/gems/json-1.7.6/lib/json/ext
/Users/mmoser/.rvm/scripts/install: line 33: /Users/mmoser/.rvm/gems/ruby-1.9.3-p362/gems/json-1.7.6/ext/json/ext/generator/scripts/functions/installer: No such file or directory
/Users/mmoser/.rvm/scripts/install: line 39: install_setup: command not found
Unrecognized option: -c
/Users/mmoser/.rvm/scripts/install: line 84: install_usage: command not found
make: *** [/Users/mmoser/.rvm/gems/ruby-1.9.3-p362/gems/json-1.7.6/lib/json/ext/generator.bundle] Error 1


Gem files will remain installed in /Users/mmoser/.rvm/gems/ruby-1.9.3-p362/gems/json-1.7.6 for inspection.
Results logged to /Users/mmoser/.rvm/gems/ruby-1.9.3-p362/gems/json-1.7.6/ext/json/ext/generator/gem_make.out

我正在拔头发。谁能解释一下?

更多信息:


xcode

maximus:~$ xcode-select --print-path
/Applications/Xcode.app/Contents/Developer

maximus:~$ la /Applications/Xcode.app/Contents/Developer/usr/bin/gcc* && la /Applications/Xcode.app/Contents/Developer/usr/bin/llvm-gcc*
lrwxr-xr-x 1 root wheel 12B Dec 24 19:22 /Applications/Xcode.app/Contents/Developer/usr/bin/gcc -> llvm-gcc-4.2
lrwxr-xr-x 1 root wheel 32B Dec 24 19:22 /Applications/Xcode.app/Contents/Developer/usr/bin/llvm-gcc -> ../llvm-gcc-4.2/bin/llvm-gcc-4.2
lrwxr-xr-x 1 root wheel 32B Dec 24 19:22 /Applications/Xcode.app/Contents/Developer/usr/bin/llvm-gcc-4.2 -> ../llvm-gcc-4.2/bin/llvm-gcc-4.2

/usr/bin

maximus:~$ la /usr/bin/gcc* && la /usr/bin/llvm-gcc*
lrwxr-xr-x 1 root wheel 12B Jan 11 19:23 /usr/bin/gcc -> llvm-gcc-4.2
lrwxr-xr-x 1 root wheel 12B Jan 11 19:23 /usr/bin/gcc-4.2 -> llvm-gcc-4.2
lrwxr-xr-x 1 root wheel 32B Dec 25 08:24 /usr/bin/llvm-gcc -> ../llvm-gcc-4.2/bin/llvm-gcc-4.2
lrwxr-xr-x 1 root wheel 32B Jan 11 19:19 /usr/bin/llvm-gcc-4.2 -> ../llvm-gcc-4.2/bin/llvm-gcc-4.2

/usr/local/bin

maximus:~$ la /usr/local/bin/gcc* && la /usr/local/bin/llvm-gcc*
lrwxr-xr-x 1 mmoser admin 46B Jan 11 21:14 /usr/local/bin/gcc-4.2 -> ../Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2
ls: /usr/local/bin/llvm-gcc*: No such file or directory

版本

maximus:~$ gcc --version
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

maximus:~$ gcc-4.2 --version
i686-apple-darwin11-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

bash_profile 包含(这就是引入 $HOME/.rvm/* 路径的内容?)

# Load RVM
if [ -f $HOME/.rvm/scripts/rvm ]; then
  source $HOME/.rvm/scripts/rvm
fi

当前回声 $PATH

/Users/mmoser/.rvm/gems/ruby-1.9.3-p362/bin
/Users/mmoser/.rvm/gems/ruby-1.9.3-p362@global/bin
/Users/mmoser/.rvm/rubies/ruby-1.9.3-p362/bin
/Users/mmoser/.rvm/bin
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
/Users/mmoser
/Users/mmoser/scripts

【问题讨论】:

【参考方案1】:

您的PATH 中似乎有/Users/mmoser/.rvm/scripts/,这不是偶然发生的 - 您必须手动添加它,请删除它并重新安装 gem。

还需要重新安装ruby,因为INSTALL被记录在ruby中:

$ rvm config-get INSTALL
/usr/bin/install -c

所以运行:

rvm reinstall all

【讨论】:

我从我的 Dropbox 帐户中为我的 dot 文件添加别名,该路径是其他东西的残余。感谢您说服我清理我的 PATH 声明,这是非常需要的;)唉,我的问题仍然存在。 (当前路径添加到问题) 砰!就是这样,很棒的酱汁。非常感谢。

以上是关于无法加载带有本机扩展的 gem:fresh 10.8、xcode 4.5、rvm的主要内容,如果未能解决你的问题,请参考以下文章

gem install rmagick -v 2.13.1 错误无法在 Mac OS 10.9.1 上构建 gem 本机扩展

Ruby with RailsInstaller,无法在 Windows 上构建 gem 本机扩展

Rails:在 OS X 上安装 PG gem - 无法构建本机扩展

使用“gem pq”安装 PostgreSQL gem 失败并出现错误:无法构建 gem 本机扩展

mac 上的 gem install rails 失败错误:无法构建 gem 本机扩展

错误:无法构建 gem 本机扩展(rails 3.2.3 上的 mysql2)