gpt4 book ai didi

ruby-on-rails - 错误 : failed to build gem native extension when installing rails on mac mountian lion os

转载 作者:数据小太阳 更新时间:2023-10-29 06:25:35 26 4
gpt4 key购买 nike

我最近更新到 Mountain Lion 并重新安装了 Ruby,但是当我尝试运行测试 Rails 应用程序时,我收到一条错误消息,指出“我的系统当前未安装 Rails”。我按照它说的做,输入 sudo gem install rails 并得到:

cleared faster_require caches due to new gem install...
Successfully installed rails-3.2.7
1 gem installed
Installing ri documentation for rails-3.2.7...
Installing RDoc documentation for rails-3.2.7...

但是当我检查安装了哪个 rails 版本时,我得到的是:

Rails is not currently installed on this system. To get the latest version, simply type:

$ sudo gem install rails

You can then rerun your "rails" command.

我也试过 gem install rails 并得到:

Building native extensions.  This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.

/Users/aileen/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
creating Makefile

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


Gem files will remain installed in /Users/aileen/.rvm/gems/ruby-1.9.3-p194@rails327/gems/json-1.7.4 for inspection.
Results logged to /Users/aileen/.rvm/gems/ruby-1.9.3-p194@rails327/gems/json-1.7.4/ext/json/ext/generator/gem_make.out

最佳答案

我看到您在 OS X 10.8.2 (Mountain lion) 上使用 ruby 1.9.3rvmrails 引用的一些 gem 可能需要 /usr/bin 中的 gcc-4.2 来构建原生 estension。

在 Mountain Lion 中,即使安装了 Xcode 4.5 CLI 工具(打开菜单 XCode - Preferences..Download -> Command Line Tools )你也会得到 /usr/bin/gcc 但不是 /usr/bin/gcc-4.2;不幸的是,某些原生扩展的构建过程依赖于/usr/bin/gcc-4.2

但是我只是在像您这样的环境中顺利安装了 rails。我之前修复了 Carina C. Zona 博客文章中讨论的环境:Fix for “make: /usr/bin/gcc-4.2: No such file or directory” ,即:

  • 确保你已经安装了 Homebrew

    brew --version

    应该报告 0.9.3 或更高

    brew update

  • 现在您可以安装 gcc-4.2 并创建一个由构建系统提供的符号链接(symbolic link)

    brew tap homebrew/dupes

    brew install apple-gcc42

    sudo ln -s /usr/local/bin/gcc-4.2 /usr/bin/gcc-4.2

  • 现在您已准备好成功安装 rails

    gem install rails

你应该得到这样的输出

Fetching: i18n-0.6.1.gem (100%)
Fetching: activesupport-3.2.8.gem (100%)
Fetching: builder-3.0.4.gem (100%)
Fetching: activemodel-3.2.8.gem (100%)
Fetching: rack-cache-1.2.gem (100%)
Fetching: rack-test-0.6.2.gem (100%)
Fetching: journey-1.0.4.gem (100%)
Fetching: hike-1.2.1.gem (100%)
Fetching: sprockets-2.1.3.gem (100%)
Fetching: erubis-2.7.0.gem (100%)
Fetching: actionpack-3.2.8.gem (100%)
Fetching: arel-3.0.2.gem (100%)
Fetching: tzinfo-0.3.34.gem (100%)
Fetching: activerecord-3.2.8.gem (100%)
Fetching: activeresource-3.2.8.gem (100%)
Fetching: polyglot-0.3.3.gem (100%)
Fetching: treetop-1.4.12.gem (100%)
Fetching: mail-2.4.4.gem (100%)
Fetching: actionmailer-3.2.8.gem (100%)
Fetching: rack-ssl-1.3.2.gem (100%)
Fetching: railties-3.2.8.gem (100%)
Fetching: rails-3.2.8.gem (100%)
Successfully installed i18n-0.6.1
Successfully installed activesupport-3.2.8
Successfully installed builder-3.0.4
Successfully installed activemodel-3.2.8
Successfully installed rack-cache-1.2
Successfully installed rack-test-0.6.2
Successfully installed journey-1.0.4
Successfully installed hike-1.2.1
Successfully installed sprockets-2.1.3
Successfully installed erubis-2.7.0
Successfully installed actionpack-3.2.8
Successfully installed arel-3.0.2
Successfully installed tzinfo-0.3.34
Successfully installed activerecord-3.2.8
Successfully installed activeresource-3.2.8
Successfully installed polyglot-0.3.3
Successfully installed treetop-1.4.12
Successfully installed mail-2.4.4
Successfully installed actionmailer-3.2.8
Successfully installed rack-ssl-1.3.2
Successfully installed railties-3.2.8
Successfully installed rails-3.2.8
22 gems installed
Installing ri documentation for i18n-0.6.1...
Building YARD (yri) index for i18n-0.6.1...
Installing ri documentation for activesupport-3.2.8...
Building YARD (yri) index for activesupport-3.2.8...
Installing ri documentation for builder-3.0.4...
Building YARD (yri) index for builder-3.0.4...
Installing ri documentation for activemodel-3.2.8...
Building YARD (yri) index for activemodel-3.2.8...
Installing ri documentation for rack-cache-1.2...
Building YARD (yri) index for rack-cache-1.2...
Installing ri documentation for rack-test-0.6.2...
Building YARD (yri) index for rack-test-0.6.2...
Installing ri documentation for journey-1.0.4...
Building YARD (yri) index for journey-1.0.4...
Installing ri documentation for hike-1.2.1...
Building YARD (yri) index for hike-1.2.1...
Installing ri documentation for sprockets-2.1.3...
Building YARD (yri) index for sprockets-2.1.3...
Installing ri documentation for erubis-2.7.0...
Building YARD (yri) index for erubis-2.7.0...
Installing ri documentation for actionpack-3.2.8...
Building YARD (yri) index for actionpack-3.2.8...
Installing ri documentation for arel-3.0.2...
Building YARD (yri) index for arel-3.0.2...
Installing ri documentation for tzinfo-0.3.34...
Building YARD (yri) index for tzinfo-0.3.34...
Installing ri documentation for activerecord-3.2.8...
Building YARD (yri) index for activerecord-3.2.8...
Installing ri documentation for activeresource-3.2.8...
Building YARD (yri) index for activeresource-3.2.8...
Installing ri documentation for polyglot-0.3.3...
Building YARD (yri) index for polyglot-0.3.3...
Installing ri documentation for treetop-1.4.12...
Building YARD (yri) index for treetop-1.4.12...
Installing ri documentation for mail-2.4.4...
Building YARD (yri) index for mail-2.4.4...
Installing ri documentation for actionmailer-3.2.8...
Building YARD (yri) index for actionmailer-3.2.8...
Installing ri documentation for rack-ssl-1.3.2...
Building YARD (yri) index for rack-ssl-1.3.2...
Installing ri documentation for railties-3.2.8...
Building YARD (yri) index for railties-3.2.8...
Installing ri documentation for rails-3.2.8...
Building YARD (yri) index for rails-3.2.8...
Installing RDoc documentation for i18n-0.6.1...
Installing RDoc documentation for activesupport-3.2.8...
Installing RDoc documentation for builder-3.0.4...
Installing RDoc documentation for activemodel-3.2.8...
Installing RDoc documentation for rack-cache-1.2...
Installing RDoc documentation for rack-test-0.6.2...
Installing RDoc documentation for journey-1.0.4...
Installing RDoc documentation for hike-1.2.1...
Installing RDoc documentation for sprockets-2.1.3...
Installing RDoc documentation for erubis-2.7.0...
Installing RDoc documentation for actionpack-3.2.8...
Installing RDoc documentation for arel-3.0.2...
Installing RDoc documentation for tzinfo-0.3.34...
Installing RDoc documentation for activerecord-3.2.8...
Installing RDoc documentation for activeresource-3.2.8...
Installing RDoc documentation for polyglot-0.3.3...
Installing RDoc documentation for treetop-1.4.12...
Installing RDoc documentation for mail-2.4.4...
Installing RDoc documentation for actionmailer-3.2.8...
Installing RDoc documentation for rack-ssl-1.3.2...
Installing RDoc documentation for railties-3.2.8...
Installing RDoc documentation for rails-3.2.8...

关于ruby-on-rails - 错误 : failed to build gem native extension when installing rails on mac mountian lion os,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11802918/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com