使用installrails.com安装rails,一切正常,直到我进入第一步:
users-MacBook:~ user$ gem install rails --no-ri --no-rdoc
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/Users/user/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20151102- 1332-1uwdkth.rb 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=/Users/user/.rvm/rubies/ruby-2.2.1/bin/$(RUBY_BASE_NAME)
--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
extconf failed, exit code 1
Gem files will remain installed in /Users/user/.rvm/gems/ruby- 2.2.1/gems/nokogiri-1.6.6.2 for inspection.
Results logged to /Users/user/.rvm/gems/ruby-2.2.1/extensions/x86_64-darwin-14/2.2.0-static/nokogiri-1.6.6.2/gem_make.out
users-MacBook:~ user$
输入后,终端输出:
{{1}}
经过一些研究后,我发现我可以通过安装Xcode命令行工具来修复它,但我需要进一步的帮助。
答案 0 :(得分:2)
错误消息告诉您到底出了什么问题:
文件" /usr/include/iconv.h"您的构建环境中缺少, 这意味着您还没有正确安装Xcode命令行工具。
如何解决问题:
要安装命令行工具,请尝试运行
xcode-select --install
终端并按照说明操作。如果失败,请打开Xcode.app, 从菜单中选择" Xcode" - "打开开发人员工具" - "更多开发者 工具"打开开发人员站点,下载适用于您的操作系统的安装程序 版本并运行它。
请检查: