Rails不会安装在我的Mac上

时间:2015-07-08 21:54:44

标签: ruby-on-rails ruby xcode macos ruby-on-rails-3

每当我尝试在我的Mac上安装Rails时它工作正常但是在我尝试查看我的Rails版本之后,终端会说我没有安装Rails。

这是我在终端上看到的内容:

admins-MBP-5:~ Programming$ sudo gem install rails
Building native extensions.  This could take a while...
ERROR:  Error installing rails:
    ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
-----
The file "/usr/include/iconv.h" is missing in your build environment,
which means you haven't installed Xcode Command Line Tools properly.

To install Command Line Tools, try running `xcode-select --install` on
terminal and follow the instructions.  If it fails, open Xcode.app,
select from the menu "Xcode" - "Open Developer Tool" - "More Developer
Tools" to open the developer site, download the installer for your OS
version and run it.
-----
*** 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
    --without-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=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
    --help
    --clean
    --use-system-libraries
    --enable-static
    --disable-static
    --with-zlib-dir
    --without-zlib-dir
    --with-zlib-include
    --without-zlib-include=${zlib-dir}/include
    --with-zlib-lib
    --without-zlib-lib=${zlib-dir}/lib
    --enable-cross-build
    --disable-cross-build


Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2/ext/nokogiri/gem_make.out
admins-MBP-5:~ Programming$ rails --version
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.

3 个答案:

答案 0 :(得分:1)

The file "/usr/include/iconv.h" is missing in your build environment,
which means you haven't installed Xcode Command Line Tools properly.

这些行告诉您无法安装XCode,这对许多控制台实用程序来说都是必需的。

此外,您使用sudo安装宝石 - 以后可能会导致一些特权问题。我建议您使用rvm来管理ruby安装,这样可以避免将来遇到很多问题。

答案 1 :(得分:1)

学习阅读错误信息将来会对你有所帮助。

try running `xcode-select --install` on
terminal and follow the instructions.  If it fails, open Xcode.app,
select from the menu "Xcode" - "Open Developer Tool" - "More Developer
Tools" to open the developer site, download the installer for your OS
version and run it.

该文本在您自己的错误消息中,请试一试。安装Xcode后,再次尝试安装Rails。

答案 2 :(得分:0)

呃,“它运作正常”???不,它根本没有 - 安装失败,因为当前的Rails需要nokogiri宝石。

阅读并遵循从'文件'开始的指示/usr/include/iconv.h“缺少'...