【问题标题】:OS X 10.8 - error trying to exec '/usr/bin/i686-apple-darwin11-gcc-4.2.1' - installing json gemOS X 10.8 - 尝试执行 '/usr/bin/i686-apple-darwin11-gcc-4.2.1' 时出错 - 安装 json gem
【发布时间】:2012-07-27 11:25:05
【问题描述】:

我刚刚升级到 OS X Mountain Lion(已经后悔了)。

在安装 json gem 的原生扩展时遇到问题。

在 10.8 之前,我安装了命令行工具。带有 Ruby 1.9.2 的 RVM。

升级到 10.8 并做了以下事情:

  • sudo chown -R whoami /usr/local
  • 酿造更新
  • brew tap homebrew/dupes
  • brew install apple-gcc42
  • 已安装 XCode 4.4
  • 为 XCode 4.4 安装的命令行工具
  • 在 bash_profile 中导出 CC=/usr/local/bin/gcc-4.2
  • sudo ln -s /usr/local/bin/gcc-4.2 /usr/bin/gcc-4.2
  • 编辑:sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

我在安装 json gem 时仍然得到以下输出:

➽ gem install json -v '1.7.4'
Building native extensions.  This could take a while...
ERROR:  Error installing json:
    ERROR: Failed to build gem native extension.

        /Users/vincent/.rvm/rubies/ruby-1.9.2-p320/bin/ruby extconf.rb
creating Makefile

make
/usr/bin/gcc-4.2 -I. -I/Users/vincent/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1/x86_64-darwin11.3.0 -I/Users/vincent/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1/ruby/backward -I/Users/vincent/.rvm/rubies/ruby-1.9.2-p320/include/ruby-1.9.1 -I. -DJSON_GENERATOR -I/Users/vincent/.rvm/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long  -fno-common -pipe -O3 -Wall -O0 -ggdb  -o generator.o -c generator.c
gcc-4.2: error trying to exec '/usr/bin/i686-apple-darwin11-gcc-4.2.1': execvp: No such file or directory
make: *** [generator.o] Error 255


Gem files will remain installed in /Users/vincent/.rvm/gems/ruby-1.9.2-p320@hshmrk/gems/json-1.7.4 for inspection.
Results logged to /Users/vincent/.rvm/gems/ruby-1.9.2-p320@hshmrk/gems/json-1.7.4/ext/json/ext/generator/gem_make.out

这里有什么帮助吗?如何调试我的构建环境?在这方面不是专家,但我认为 json gem 安装程序忽略了我的环境,因为它使用的 GCC 版本在我的系统上不存在,而且 brew 安装程序也没有创建它。

➽ gcc-4.2
i686-apple-darwin11-gcc-4.2.1: no input files

➽ which gcc-4.2
/usr/local/bin/gcc-4.2

➽ ls /usr/bin/i686-apple-darwin11-gcc-4.2.1
ls: /usr/bin/i686-apple-darwin11-gcc-4.2.1: No such file or directory

我还尝试了符号链接 ➽ sudo link /usr/local/bin/gcc-4.2 /usr/bin/i686-apple-darwin11-gcc-4.2.1。但这给出了 vfork 超时错误。

编辑:

➽ brew doctor
gcc-4.2: error trying to exec '/usr/bin/i686-apple-darwin11-gcc-4.2.1': execvp: No such file or directory
Warning: X11 is not installed.
You don't have X11 installed as part of your OS X installation.
This is not required for all formulae, but is expected by some.
You can download the latest version of XQuartz from:
  https://xquartz.macosforge.org

编辑2:

确实运行了 xcode-select XCode

编辑3:

sudo xcode-select -switch /usr/bin
sudo ln -sf /usr/bin/llvm-gcc-4.2 /usr/bin/gcc-4.2

这解决了它!基本上,您告诉 OS X 使用 /usr/bin 文件夹进行编译,然后将 llvm-gcc-4.2 编译器链接到旧编译器所在的位置。作品!砰!

来源:http://jtimberman.housepub.org/blog/2012/02/26/xcode-command-line-tools/

【问题讨论】:

    标签: macos gcc rubygems


    【解决方案1】:

    更简单的方法.. 我只是通过编辑 rbconfig.rb 文件解决了根本问题 ~/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/x86_64-darwin12.2.0

    由于某种原因,该文件被设置为使用 gcc-4.2 进行 CC 而不是仅计划 gcc(即 llvm-gcc-4.2)。

    【讨论】:

      【解决方案2】:
      sudo xcode-select -switch /usr/bin
      sudo ln -sf /usr/bin/llvm-gcc-4.2 /usr/bin/gcc-4.2
      

      【讨论】:

        【解决方案3】:

        我的印象是你需要做的就是:

        sudo ln -sf /usr/bin/llvm-gcc-4.2 /usr/bin/gcc-4.2
        

        我尝试使用 xcode-select XCode 和命令行工具。他们都工作。 我还卸载了 brew apple-gcc42,它仍然有效。 也不需要导出 CC。

        所以基本上只是链接。希望这能解决人们遇到的一些问题。

        【讨论】:

          【解决方案4】:

          你跑了吗:

          sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
          

          让您的系统使用 Xcode 提供的命令行工具?

          SO answer 的更多内容。

          【讨论】:

          • 道歉。我确实运行过。不在我所做的事情清单中。为了安全起见,我又做了一次,仍然没有骰子。但这是意料之中的,因为 XCode 不再包含 gcc-4.2。仅限 LLVM。我会更新我的问题。
          • OMGWTFBBQ!!!!我找到了!我会更新的。不过,您的回答将我推向了正确的方向。
          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2013-06-10
          • 2014-01-06
          • 2012-07-27
          • 2016-01-22
          • 2018-05-16
          • 1970-01-01
          • 2016-01-22
          相关资源
          最近更新 更多