最近有门课要写一个简单的Web应用,以前写Web都是用Java写的,由于以前搞Cloud Foundry开发的时候用过一段时间的Ruby,想想这次还是用Ruby On Rails写算了,能节省很多时间。由于Ruby电脑上已经有了,所以直接安装Rails就可以了。
sudo gem install rails
额,但是很快就报错了。。。
Errno::ECONNRESET: Connection reset by peer - SSL_connect (https://api.rubygems.org
貌似因为被墙的原因,好像下载失败。虽然翻墙也容易,但是我想还是介绍一下不翻墙的解决办法吧。主要就是修改gem的源,由于墙的原因,rails官方的源似乎无法访问,那么只能改成taobao的源了。输入以下命令:
gem sources -l
gem sources --remove https://rubygems.org/
gem sources -a https://ruby.taobao.org/
gem sources -l
其中gem sources -l是显示源列表,这里先将官方的源删除再添加taobao的源,如果最后结果如下,说明添加成功:
*** CURRENT SOURCES ***
https://ruby.taobao.org/
接下来再安装rails还是失败。。。
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/Users/nmacaule/.rvm/rubies/ruby-2.2.0/bin/ruby -r ./siteconf20150209-56320-1m9byas.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-op